Skip to content

Bug: URI parsing fails for short format paths (e.g., '/resources' instead of 'viking://resources') #259

@yuevthins

Description

@yuevthins

Environment

  • OpenViking version: 0.1.17
  • Python version: 3.14.2
  • OS: macOS (arm64)

Bug Description

Issue 1: URI path conversion truncates paths

In openviking/storage/viking_fs.py, the _uri_to_path method assumes all URIs start with viking://, but some internal calls pass short-format paths like /resources.

Current code:

def _uri_to_path(self, uri: str) -> str:
    remainder = uri[len("viking://") :].strip("/")
    # When uri='/resources', this becomes '/s' (truncated!)

Result: /resources gets converted to /local/s instead of /local/resources, causing "no such directory: /s" errors.

Suggested fix:

def _uri_to_path(self, uri: str) -> str:
    if uri.startswith("viking://"):
        remainder = uri[len("viking://"):].strip("/")
    elif uri.startswith("/"):
        remainder = uri.strip("/")
    else:
        remainder = uri.strip("/")
    
    if not remainder:
        return "/local"
    return f"/local/{remainder}"

Issue 2: VikingURI class rejects short-format URIs

In openviking_cli/utils/uri.py, the VikingURI class raises an error for paths not starting with viking://.

Suggested fix: Auto-complete the prefix for short-format paths:

def _parse(self) -> Dict[str, str]:
    if not self.uri.startswith(f"{self.SCHEME}://"):
        clean_path = self.uri.lstrip("/")
        self.uri = f"{self.SCHEME}://{clean_path}"
    # ... rest of parsing

Steps to Reproduce

import openviking as ov

client = ov.SyncOpenViking(path='./data')
client.initialize()

# This fails with 'no such directory: /s'
client.ls('/resources')  

# This works
client.ls('viking://resources')

Additional Note

There also seems to be an issue with embedding/semantic processing not being triggered after add_resource(). The wait_processed() returns {'Embedding': {'processed': 0}, 'Semantic': {'processed': 0}} even after adding files.


Happy to submit a PR with the fixes if helpful! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions