Skip to content

Conversation

@adit-chandra
Copy link
Contributor

@adit-chandra adit-chandra commented Oct 27, 2025

re Issue #45: fix s3 bucket prefix construction for refs in delete command

Currently, the delete command builds up the s3 bucket prefix without a trailing forward slash. These leads to a bug where attempting to delete a branch whose name prefixes another existing branch name will result in "not found" error.
This happens because s3 will resolve the prefix two all refs whose keys share the same prefix provided to ListObjectsV2. There's an additional bug, where if the number of objects return != 1 (or 2 for zip schemes), then the delete command assumes the number of objects is 0 and returns a "not found" err.

Fix this by:

  1. appending a trailing forward slash to the ref name to break any possible substring prefix matches on branch name. This matches existing ListObjectsV2 calls in the library that append a trailing /. e.g. see get_bundles_for_ref, remote_remote_ref
  2. add additional error handling to distinguish between true "not found" [0 objects found] vs duplicate refs found [>1 objects found].

Test plan:

  • git checkout -b boba && git push
  • git checkout -b boba-fett && git push
  • git push --delete origin boba
  • Confirmed deleting boba now works even when boba-fett already exists in the remote s3 bucket.

@massi-ang
Copy link
Contributor

Thanks Adit for your contribution

@massi-ang massi-ang merged commit 1ef7059 into awslabs:main Oct 31, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants