OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: viking_read on a directory URI returns bare INVALID_ARGUMENT instead of degrading to .overview.md / children

Open livechenjt-prog opened this issue 4 months ago • 0 comments

Issue Origin

Observed or reproduced in a real environment

Bug Description

viking_read (and the underlying read API) refuses directory URIs with a hard INVALID_ARGUMENT: Cannot read directory as file error, even when the directory has a generated .overview.md / .abstract.md and readable child files. This forces every caller to do a 3-step dance (list → pick a leaf → read) just to look at the directory's own content.

The API surface is inconsistent with find / search, which already understand directories and route to overview / children automatically.

Steps to Reproduce

  1. Have any resource directory with an auto-generated overview, e.g. viking://resources/leq_qgyg_kanban/ (a KANBAN board directory with two child .md files and .overview.md).
  2. Call read on the directory URI directly:
viking_read(uri="viking://resources/leq_qgyg_kanban/")
  1. Server returns:
INVALID_ARGUMENT: Cannot read directory as file: viking://resources/leq_qgyg_kanban/

Expected Behavior

read on a directory URI should transparently degrade to a sensible default, matching how find / search already treat directories. Any of the following would be acceptable:

  • level=overview / abstract → return the auto-generated .overview.md / .abstract.md content.
  • level=full → return concatenated children (with per-child head truncation and total-size guard).
  • Or, at minimum, return a structured hint ({"error":"is_directory","children":[...],"overview_uri":"..."}) instead of a bare INVALID_ARGUMENT, so the agent can react without doing a separate browse list call.

Actual Behavior

Bare INVALID_ARGUMENT: Cannot read directory as file. No pointer to .overview.md, no child list, no suggestion. The caller has to know to fall back to browse list and then read a specific leaf.

Minimal Reproducible Example

# fails
client.read("viking://resources/leq_qgyg_kanban/")

# workaround (3 calls to do what feels like 1)
entries = client.browse("list", "viking://resources/leq_qgyg_kanban/")
first_leaf = entries[0]["uri"]
content = client.read(first_leaf)

Error Logs

INVALID_ARGUMENT: Cannot read directory as file: viking://resources/leq_qgyg_kanban/

OpenViking Version

0.4.7

Python Version

3.10

Operating System

Linux

Model Backend

Volcengine (Doubao)

Additional Context

  • Observed while an LLM agent tried to read a KANBAN board directory that was known (by the agent) to have .overview.md. The agent had to be re-prompted to run browse list first, which is exactly the friction .overview.md is meant to remove.
  • Related but distinct: #2383 (repeated add_resource re-embeds unchanged content) — same "directory should be first-class" theme, different API. Complementary, not duplicate.
  • Sibling issues in this batch: #3306 (add_resource timeout returns no task_id) and #3307 (content-aware add_resource). All three fall under "make viking:// directory / URI semantics symmetric across read / write paths".

livechenjt-prog avatar Jul 16 '26 14:07 livechenjt-prog