Skip to content

fix: ensure refreshed eTag before update distribution#128

Merged
caiofralmeida merged 1 commit into
mainfrom
fix-precondition-failed-etag
Apr 7, 2026
Merged

fix: ensure refreshed eTag before update distribution#128
caiofralmeida merged 1 commit into
mainfrom
fix-precondition-failed-etag

Conversation

@caiofralmeida

@caiofralmeida caiofralmeida commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

This pull request addresses an issue with stale ETags during CloudFront distribution sync operations and updates related tests to match the new behavior. The main change ensures that a fresh ETag is always fetched before updating a distribution to avoid PreconditionFailed errors. The test suite has been updated to reflect the additional call to fetch the latest distribution configuration.

CloudFront Distribution Sync Improvements:

  • In internal/cloudfront/repository.go, the Sync method now fetches a fresh distribution configuration and ETag immediately before updating, preventing PreconditionFailed errors caused by stale ETags during OAC sync operations.

Test Suite Updates:

  • Updated multiple test cases in internal/cloudfront/repository_test.go to expect an additional call to GetDistributionConfig, reflecting the new logic that fetches a fresh ETag before updating:
    • TestSync_CantUpdateDistribution
    • TestSync_CantSaveTags
    • TestSync_OriginDoesNotExistYet
    • TestSync_OriginAlreadyExists
    • TestSync_BehaviorDoesNotExistYet
    • TestSync_BehaviorAlreadyExists
    • TestUpdate_ShouldSyncOneOACAndDeleteOn

@caiofralmeida caiofralmeida merged commit e786637 into main Apr 7, 2026
2 checks passed
@caiofralmeida caiofralmeida deleted the fix-precondition-failed-etag branch April 7, 2026 18:15
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