fix(resource): resolve 'file exists' errors on resource add#845
Merged
qin-ctx merged 2 commits intovolcengine:mainfrom Mar 21, 2026
Merged
fix(resource): resolve 'file exists' errors on resource add#845qin-ctx merged 2 commits intovolcengine:mainfrom
qin-ctx merged 2 commits intovolcengine:mainfrom
Conversation
Two bugs caused mv to fail with "file exists" during add_resource: 1. When `to` URI has a trailing slash, parent_uri was computed as the target directory itself instead of its parent. mkdir then created the exact path that mv was about to rename into. 2. _resolve_unique_uri in Phase 3.5 ran outside bind_request_context, so stat checked the default account path instead of the actual account. On repeated adds it failed to detect the existing resource and returned the original URI, causing mv to collide. Also pass ctx to viking_fs calls in index_resource that were missing it.
|
|
|
Failed to generate code suggestions for PR |
qin-ctx
approved these changes
Mar 21, 2026
zeattacker
pushed a commit
to zeattacker/OpenViking
that referenced
this pull request
Mar 21, 2026
…ne#845) * fix(resource): resolve 'file exists' errors on resource add Two bugs caused mv to fail with "file exists" during add_resource: 1. When `to` URI has a trailing slash, parent_uri was computed as the target directory itself instead of its parent. mkdir then created the exact path that mv was about to rename into. 2. _resolve_unique_uri in Phase 3.5 ran outside bind_request_context, so stat checked the default account path instead of the actual account. On repeated adds it failed to detect the existing resource and returned the original URI, causing mv to collide. Also pass ctx to viking_fs calls in index_resource that were missing it. * Update GUIDE.md --------- Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com>
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.
Description
Fix two bugs in
resource_processor.pyPhase 3.5 that causedmvto fail with "file exists" when adding resources, plus a minor ctx propagation fix inembedding_utils.py.Related Issue
Fixes #846
Type of Change
Changes Made
toURI: Whentoparameter ends with/,parent_uriwas incorrectly computed as the target directory itself (instead of its parent).mkdirthen pre-created the exact path thatmvwas about to rename into, causing 100% failure. Fixed by stripping trailing slash beforersplit._resolve_unique_uri: The Phase 3.5 call to_resolve_unique_uriran outsidebind_request_context, sostatchecked the default account (/local/default/) instead of the actual account (e.g.,/local/coral/). On repeated adds of the same resource name, it failed to detect the existing resource and returned the original URI, colliding with the existing path. Fixed by wrapping inbind_request_context(ctx).embedding_utils.py:index_resourcehadctxavailable but didn't pass it toviking_fs.exists()andviking_fs.read_file()calls for.abstract.md/.overview.md.Testing
Checklist
Screenshots (if applicable)
N/A
Additional Notes
Reproduction (Bug 1 - trailing slash): Call
add_resourcewithto="viking://resources/foo/"— first add fails immediately.Reproduction (Bug 2 - missing context): On a non-default account, run
ov add-resource file.mdtwice — second add fails with "file exists".