Repository navigation
fix: don't delete sibling prefixes when delete is enabled - #3
Merged
Merged
Conversation
The target was used as a raw S3 list prefix without a trailing slash, so syncing to "app/feature/x" also listed "app/feature/x-other/...". With delete: true those keys were not found locally and got deleted. List with a trailing-slash prefix and only consider keys below it as delete candidates. Adds unit tests.
zyclonite
approved these changes
Oct 1, 2026
zyclonite
left a comment
Member
There was a problem hiding this comment.
lgtm
please test as soon as the main branch artifact is built
This branch was successfully deployed
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.
Summary
With
delete: true, syncing to a target also deleted objects in sibling prefixes that share the same leading string.List()used the target as a raw S3 prefix without a trailing slash, so a target ofapp/feature/xalso listedapp/feature/x-other/...andapp/feature/xy/.... Those keys don't exist in the local source, so they became delete jobs and were removed. In practice, deploying branchfeature/foowiped the deployment offeature/foo-barin the same bucket.Changes
listPrefix(target): trims slashes and appends/. The bucket root stays"".deleteCandidates(remote, local, target): only keys strictly below the target prefix can be deleted (defense in depth). Lookup now uses a map instead of a nested loop.createSyncJobsuses both. Upload keys and the CloudFront invalidation path are unchanged.Testing
plugin_test.go(new): sibling prefixes are ignored, a target with leading/trailing slashes works, and bucket-root sync still deletes stale keys.go vet ./...,go test ./...andgo buildpass locally (Go 1.27).