fix(storage): idempotent rm/mv operations with vector index sync#284
Merged
qin-ctx merged 3 commits intovolcengine:mainfrom Feb 25, 2026
Merged
Conversation
1810419 to
ab9a903
Compare
- AGFS Server (Go): Use filesystem.NewNotFoundError() instead of fmt.Errorf() so mapErrorToStatus() returns 404 instead of 500 - Affected plugins: localfs, memfs, queuefs, serverinfofs - AGFS SDK (Python): rm() defaults to force=True (like rm -f) - 404 returns success instead of raising exception - Use AGFSHTTPError with status_code for HTTP errors - VikingFS: rm() and mv() are now idempotent - Deleting non-existent file succeeds and cleans orphan index - mv() cleans all orphan indices when source not found (404) This follows industry standards (Linux rm -f, AWS S3 DeleteObject) where delete operations are idempotent by default.
ab9a903 to
d4577b9
Compare
Extend NewNotFoundError usage to Read, ReadDir, Open, and Grep operations for consistent HTTP 404 responses across all plugins.
When server returns JSON body with error message, the old code would raise AGFSClientError (without status_code) instead of AGFSHTTPError. This broke the force=True logic in rm() which checks status_code == 404. Now all HTTP errors use AGFSHTTPError consistently, preserving the status_code for callers that need to handle specific HTTP status codes. Root cause: Original upstream code had this design flaw - JSON parsing success path would lose status_code. This was not exposed before because no code depended on status_code until we added force=True for rm().
qin-ctx
reviewed
Feb 25, 2026
| if err != nil { | ||
| if os.IsNotExist(err) { | ||
| return nil, fmt.Errorf("no such file: %s", path) | ||
| return nil, filesystem.NewNotFoundError("grep", path) |
qin-ctx
approved these changes
Feb 25, 2026
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
Make file deletion (
rm) and move (mv) operations idempotent, ensuring vector index consistency. When deleting/moving a non-existent file, the operation succeeds instead of failing, and any orphan vector index records are cleaned up.This follows industry standards:
rm -f- ignores nonexistent filesDeleteObject- returns success for non-existent keysRelated Issue
Type of Change
Changes Made
AGFS Server (Go): Fixed HTTP status code for non-existent files
fmt.Errorf("no such file...")tofilesystem.NewNotFoundError()somapErrorToStatus()returns 404 instead of 500localfs,memfs,queuefs,serverinfofsAGFS SDK (Python): Added
forceparameter torm()methodforce=True(likerm -f){"message": "deleted"}instead of raising exceptionAGFSHTTPErrorwithstatus_codeattribute for better error handlingVikingFS: Idempotent
rm()andmv()with vector index cleanuprm(): Deleting non-existent file succeeds and cleans any orphan index recordsmv(): When source not found (404), cleans all related URIs from vector indexTesting
Checklist
Screenshots (if applicable)
N/A
Additional Notes
Before (500 error for non-existent file):
Server returned 500 Internal Server Error with message "no such file or directory"
After (graceful success):
Deleting non-existent file succeeds silently and returns {"message": "deleted"}
Why Idempotent Delete Matters
In distributed systems and concurrent environments, idempotent operations are crucial for: