fix: support short-format URI paths in VikingFS and VikingURI#281
Open
r266-tech wants to merge 1 commit intovolcengine:mainfrom
Open
fix: support short-format URI paths in VikingFS and VikingURI#281r266-tech wants to merge 1 commit intovolcengine:mainfrom
r266-tech wants to merge 1 commit intovolcengine:mainfrom
Conversation
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
|
|
Collaborator
|
viking_fs.py has undergone a major refactoring, and you need to adapt to the new code and resolve the conflicts." |
6 tasks
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
Fixes #259 — URI parsing fails for short format paths (e.g.,
/resourcesinstead ofviking://resources).Problem
Two related bugs in URI handling:
1.
VikingFS._uri_to_path()truncates short-format pathsWhen
uri='/resources', the method blindly strips the first 9 characters (len('viking://')), resulting in:/resources→ Expected:/local/resources→ Actual:/local/s❌2.
VikingURI._parse()rejects short-format URIsRaises
ValueErrorfor paths not starting withviking://, even thoughVikingURI.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 existingnormalize()static method, instead of raising ValueError.Tests
Added
tests/test_uri_short_format.pywith 15 test cases covering:VikingURIshort-format parsing (slash prefix, bare path, nested paths, invalid scope rejection)VikingFS._uri_to_pathshort-format conversion (all three formats, edge cases like root/empty)All existing tests continue to pass.