Repository navigation
fix(files): return errors from files rm instead of emitting them - #11491
Open
amalsaidov wants to merge 1 commit into
Open
amalsaidov wants to merge 1 commit into
amalsaidov wants to merge 1 commit into
Conversation
files rm emitted each failure as a stream output value and then returned a generic "can't remove some files" error. Over the RPC API this made /api/v0/files/rm answer with HTTP 200 and a plain, non-JSON string body on failure, a regression introduced in v0.11 that broke clients decoding the error response. Return the joined errors instead. The command now responds with HTTP 500 and a JSON error body, and reports every failing path rather than a generic message. On the CLI this surfaces the real error on stderr with a non-zero exit code. Added a test/cli regression test covering the RPC JSON error response and the multi-path failure output. AI-assisted; directed, reviewed and tested by the author.
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.
This fixes a regression in how
ipfs files rmreports failures.Problem
When a path cannot be removed (for example removing an MFS path that does not exist), the command emitted each error as a regular stream output value and then returned a generic
can't remove some fileserror. Over the RPC API this made/api/v0/files/rmrespond withHTTP 200and a plain, non-JSON string body, so clients that decode the error response got invalid JSON. This is a regression from v0.11 (the behavior in v0.10 wasHTTP 500with a JSON error body).Fix
Return the errors (
errors.Join) instead of emitting them. The RPC API now answers withHTTP 500and a JSON error body:When several paths fail, all failures are reported instead of a single generic message. On the CLI the real error is printed to stderr with a non-zero exit code, and the success path stays silent (like Unix
rm).Testing
Added
test/clicoverage underTestFilesRm:files rmof a missing path over the RPC API returnsHTTP 500with a valid JSON error body.files rmof several missing paths reports each failing path.Verified locally:
go build ./core/commands/...go test ./core/commands/...go test ./test/cli/... -run TestFilesRm -v(all subtests pass)gofmt -lclean,go vetcleanAI-assisted; directed, reviewed and tested by the author.
References