fix(openviking): resolve viking_read 500/412 on file URIs and pseudo-summary URIs (salvage #5886 + #12757 + #12937) - #17869
Merged
Merged
Conversation
OpenViking v0.3.3 expects directory URIs for abstract/overview reads. Passing pseudo-files like /.overview.md and /.abstract.md to /api/v1/content/overview|abstract triggers HTTP 500. This change normalizes those pseudo-URIs to their parent directory for abstract/overview requests, preserves full reads, and hardens parsing for wrapped/unwrapped result payloads and fs list response shapes.
OpenViking returns 500 for /content/abstract and /content/overview when URI points to mem_*.md files. Add resilient fallback to /content/read for non-pseudo summary file URIs while preserving pseudo summary normalization. Also add regression tests for fallback behavior.
…directory-only endpoints Adds a deterministic pre-check on top of htsh's exception-based fallback: before calling /content/abstract or /content/overview on a non-pseudo URI, probe /api/v1/fs/stat. If the server says the URI is a file, route straight to /content/read instead of eating a failing 500 round-trip. This is the same idea pty819 and chennest independently landed in PRs #12757 and #12937 — merged here on top of htsh's broader fix so we keep pseudo-URI normalization and v0.3.3 browse-shape handling while avoiding the slow exception path on servers that return a raised 500 every time. The exception fallback from #5886 stays in place for environments where fs/stat is unavailable or returns an unfamiliar shape. Also credits pty819, chennest, and htsh in AUTHOR_MAP so future release notes attribute them correctly.
This was referenced Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
viking_readno longer returns 500/412 against live OpenViking servers for file URIs or pseudo-summary URIs.Salvages @htsh's PR #5886 with its 3 original commits intact, then adds an
fs/statpre-check on top — the same idea @pty819 (#12757) and @chennest (#12937) independently arrived at.Root cause
OpenViking's
/api/v1/content/abstractand/api/v1/content/overviewendpoints are directory-only. The plugin was forwarding both pseudo-summary file URIs (viking://.../.overview.md) and real file URIs (mem_*.md) to them, which the server rejected with HTTP 500 (v0.3.3) / 412 (newer builds).Changes
plugins/memory/openviking/__init__.py:/.overview.md,/.abstract.md,/.read.md,/.full.md) to parent directory before the request (from fix(openviking): prevent v0.3.3 HTTP 500s by normalizing /.overview.md and /.abstract.md pseudo-URIs before content reads #5886){result: ...}payloads regardless of shape (from fix(openviking): prevent v0.3.3 HTTP 500s by normalizing /.overview.md and /.abstract.md pseudo-URIs before content reads #5886)browseparsing for v0.3.3 response drift —listvsdict,isDirvsis_dir, missingname(from fix(openviking): prevent v0.3.3 HTTP 500s by normalizing /.overview.md and /.abstract.md pseudo-URIs before content reads #5886)/content/readon summary-level failure (from fix(openviking): prevent v0.3.3 HTTP 500s by normalizing /.overview.md and /.abstract.md pseudo-URIs before content reads #5886)_is_directory_uri()— pre-check via/api/v1/fs/statbefore a summary request. If the server says it's a file, route straight to/content/readand avoid the failing round-trip (idea from fix(openviking): route viking_read to correct endpoint for file URIs #12757 / fix(openviking): viking_read fails on file URIs — route to /content/read #12937)tests/openviking_plugin/test_openviking.py: 9 tests covering URI normalization, pseudo-URI path, stat-probe fast path, stat-probe-unavailable → exception fallback, directory URI via stat, full reads, browse shape handlingscripts/release.pyAUTHOR_MAP: credit htsh, pty819, chennestWhy keep both the pre-check AND the exception fallback
The pre-check (
fs/stat) is the fast path when the server cooperates — it avoids a failing/content/overviewround-trip. The exception fallback (#5886's original approach) is the safety net whenfs/statis unavailable, returns an unfamiliar shape, or is slower than eating the 500. Keeping both means no regression for any OpenViking version that #5886 already supported.Credit
fs/statpre-check. Wired in here on top of htsh's base.Validation
tests/openviking_plugin/level=overviewfs/stat→/content/read/.overview.md/content/overviewlevel=overviewCloses #5886
Closes #12757
Closes #12937
Fixes #12755