Skip to content

fix: support short-format URI paths in VikingFS and VikingURI#281

Open
r266-tech wants to merge 1 commit intovolcengine:mainfrom
r266-tech:fix/uri-short-format-parsing
Open

fix: support short-format URI paths in VikingFS and VikingURI#281
r266-tech wants to merge 1 commit intovolcengine:mainfrom
r266-tech:fix/uri-short-format-parsing

Conversation

@r266-tech
Copy link

Summary

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

Problem

Two related bugs in URI handling:

1. VikingFS._uri_to_path() truncates short-format paths

When uri='/resources', the method blindly strips the first 9 characters (len('viking://')), resulting in:

  • Input: /resources → Expected: /local/resources → Actual: /local/s

2. VikingURI._parse() rejects short-format URIs

Raises ValueError for paths not starting with viking://, even though VikingURI.normalize() already exists to handle this conversion.

Fix

  • VikingFS._uri_to_path: Check URI format before stripping prefix. Correctly handles three formats:

    • viking://resources/local/resources ✅ (unchanged)
    • /resources/local/resources ✅ (fixed)
    • resources/local/resources ✅ (fixed)
  • VikingURI._parse: Auto-normalize short-format paths using the existing normalize() static method, instead of raising ValueError.

Tests

Added tests/test_uri_short_format.py with 15 test cases covering:

  • VikingURI short-format parsing (slash prefix, bare path, nested paths, invalid scope rejection)
  • VikingFS._uri_to_path short-format conversion (all three formats, edge cases like root/empty)

All existing tests continue to pass.

Previously, passing short-format paths like '/resources' or 'resources'
(without the 'viking://' prefix) to VikingFS._uri_to_path() caused
incorrect path conversion. For example, '/resources' was truncated to
'/local/s' instead of '/local/resources', because the method blindly
stripped the first 9 characters (len('viking://')) regardless of format.

Similarly, VikingURI._parse() would raise ValueError for any URI not
starting with 'viking://', even though the existing normalize() method
already handled this conversion.

Changes:
- VikingFS._uri_to_path: Check URI format before stripping prefix;
  handle 'viking://', '/' prefix, and bare paths correctly
- VikingURI._parse: Auto-normalize short-format paths using the
  existing normalize() static method instead of raising ValueError
- Add comprehensive tests for both fixes

Fixes volcengine#259
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@MaojiaSheng MaojiaSheng requested a review from qin-ctx February 25, 2026 09:43
@qin-ctx qin-ctx self-assigned this Feb 25, 2026
@qin-ctx
Copy link
Collaborator

qin-ctx commented Feb 25, 2026

viking_fs.py has undergone a major refactoring, and you need to adapt to the new code and resolve the conflicts."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

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

3 participants