fix(rm): allow deletion of DIROBJ objects via --raw (#834)#861
Open
gustcol wants to merge 1 commit intopeak:masterfrom
Open
fix(rm): allow deletion of DIROBJ objects via --raw (#834)#861gustcol wants to merge 1 commit intopeak:masterfrom
gustcol wants to merge 1 commit intopeak:masterfrom
Conversation
Fixes peak#834 url.IsPrefix() returns true for any remote path ending with "/", which caused validateRMCommand to reject those paths with the bucket/prefix guard. However, S3 allows zero-byte "directory marker" objects whose keys end with "/" — they are real, deletable objects, not prefixes. When the caller passes --raw, wildcard expansion is already disabled. Applying the same opt-out to the prefix guard is semantically correct: the user is explicitly targeting a specific key, not a prefix glob. Reproducer: s5cmd rm s3://bucket/dirobj/ # ERROR: bucket/prefix cannot be used s5cmd rm --raw s3://bucket/dirobj/ # should succeed After this change: The --raw path skips the IsPrefix() guard and reaches the S3 API.
Author
Test resultsUnit tests ( Specific tests: Wasabi smoke test: Prefix guard without |
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.
Context
Fixes #834
Root cause
url.IsPrefix()returnstruefor any remote path ending with/.validateRMCommandunconditionally checked this and rejected keysending with
/with the message "s3 bucket/prefix cannot be usedfor delete operations".
However, S3 allows zero-byte directory marker objects (keys ending
with
/). These are real, deletable objects — not S3 prefixes — andare created by tools like the AWS Console, Cyberduck, or s3cmd.
Fix
When
--rawis set the user has explicitly opted out of wildcard andprefix treatment. The fix extends that opt-out to the
IsPrefix()guardin
validateRMCommand:IsRaw()was already present onURL(it exposed the unexportedrawfield). No new public API was added.
Files changed:
command/rm.goTests
TestRemoveCommand_DirobjKeyWithRawFlag— passess3://bucket/dirobj/with--raw; expects no validation error.TestRemoveCommand_PrefixWithoutRawFlag— regression guard confirming the guard still rejects prefix keys without--raw.Manual verification