Skip to content

fix: Correct legacy etag handling logic - #3637

Merged
stevehipwell merged 1 commit into
mainfrom
stevehipwell/fix-legacy-etag-logic
Sep 9, 2026
Merged

stevehipwell merged 1 commit into
mainfrom
stevehipwell/fix-legacy-etag-logic

Conversation

@stevehipwell

Copy link
Copy Markdown
Collaborator

Resolves #3519

This PR reverts the changes made in #3311 & #2840. While this change is technically a breaking change, anyone setting the etag attribute on a resource will have broken the provider and as such this change shouldn't require a Semver major bump. Note that the removed tests weren't functional and that the new implementation relies on documented Terraform Plugin SDK v2 behaviour.


Before the change?

  • The legacy etag attribute for resources had been made optional to support suppressing the diff which is fundamentally incorrect
  • When using the legacy etag logic, update failures could result in the provider no longer tracking the required changes

After the change?

  • The legacy etag attribute is suppressed in all diffs
  • Before a resource with legacy etag support is update the cached value is cleared to prevent stale reads

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@stevehipwell stevehipwell added this to the v6.14.0 milestone Sep 9, 2026
@stevehipwell
stevehipwell requested review from deiga and a balanced review from Copilot September 9, 2026 10:26
@stevehipwell stevehipwell self-assigned this Sep 9, 2026
@stevehipwell stevehipwell added the Type: Bug Something isn't working as documented label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

👋 Hi, and thank you for this contribution!

This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical validation and stale-state issues remain, alongside schema compatibility and regression-test concerns.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This pull request revises legacy ETag handling to prevent stale Terraform state after failed updates.

Changes:

  • Makes resource ETags computed-only and suppresses their planned diffs.
  • Clears cached ETags before updates.
  • Reclassifies ETag documentation as read-only.
  • Removes legacy ETag tests.
File summaries
File Description
github/util_diff.go Adds shared ETag diff clearing; regression coverage is needed.
github/resource_organization_block.go Updates ETag schema handling.
github/resource_github_user_ssh_key.go Updates ETag schema handling.
github/resource_github_user_gpg_key.go Updates ETag schema handling.
github/resource_github_team.go Clears ETag during team updates.
github/resource_github_team_sync_group_mapping.go Clears ETag during mapping updates.
github/resource_github_team_repository.go Clears ETag during repository updates.
github/resource_github_team_membership.go Clears ETag during membership updates.
github/resource_github_repository.go Revises ETag behavior; update ordering and schema compatibility require changes.
github/resource_github_repository_webhook.go Clears ETag during webhook updates.
github/resource_github_repository_ruleset.go Revises ruleset ETag handling.
github/resource_github_repository_project.go Updates ETag schema handling.
github/resource_github_repository_deployment_branch_policy.go Clears ETag before updates.
github/resource_github_repository_deploy_key.go Updates ETag schema handling.
github/resource_github_repository_autolink_reference.go Updates ETag schema handling.
github/resource_github_release.go Revises release ETag behavior.
github/resource_github_project_column.go Updates ETag schema handling.
github/resource_github_project_card.go Updates ETag schema handling.
github/resource_github_organization_webhook.go Clears ETag during webhook updates.
github/resource_github_organization_ruleset.go Revises ruleset ETag handling.
github/resource_github_organization_project.go Updates ETag schema handling.
github/resource_github_membership.go Clears ETag during membership updates.
github/resource_github_issue.go Clears ETag during issue updates.
github/resource_github_issue_label.go Clears ETag during label updates.
github/resource_github_etag_unit_test.go Removes legacy ETag unit tests.
github/resource_github_etag_acc_test.go Removes legacy ETag acceptance tests.
github/resource_github_enterprise_actions_runner_group.go Clears ETag during updates.
github/resource_github_emu_group_mapping.go Revises mapping ETag behavior.
github/resource_github_branch.go Clears ETag during branch updates.
github/resource_github_branch_protection_v3.go Clears ETag during updates.
github/resource_github_branch_default.go Revises default-branch ETag handling.
github/resource_github_actions_runner_group.go Clears ETag during updates.
github/data_source_github_ref.go Adds unsupported data-source CustomizeDiff; removal is required.
github/data_source_github_membership.go Adds unsupported data-source CustomizeDiff; removal is required.
github/data_source_github_branch.go Adds unsupported data-source CustomizeDiff; removal is required.
docs/resources/repository.md Marks ETag read-only.
docs/resources/release.md Marks ETag read-only.
docs/resources/branch_default.md Marks ETag read-only.
Review details
  • Files reviewed: 38/38 changed files
  • Comments generated: 6
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread github/data_source_github_branch.go Resolved
Comment thread github/data_source_github_membership.go Resolved
Comment thread github/data_source_github_ref.go Resolved
Comment thread github/resource_github_repository.go Resolved
Comment thread github/resource_github_repository.go Resolved
Comment thread github/util_diff.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The reviewed changes have no unresolved blocking issues.

Review details
  • Files reviewed: 35/35 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@stevehipwell stevehipwell added the needs-github-review Request a review from GitHub label Sep 9, 2026
@team-review-router
team-review-router Bot requested a review from a team September 9, 2026 11:46

@deiga deiga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@robert-crandall robert-crandall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for fixing the failed-update drift issue and simplifying the ETag handling!

@stevehipwell
stevehipwell merged commit 8935446 into main Sep 9, 2026
16 checks passed
@stevehipwell
stevehipwell deleted the stevehipwell/fix-legacy-etag-logic branch September 9, 2026 16:56
simonostendorf added a commit to simonostendorf/fork-integrations-terraform-provider-github that referenced this pull request Sep 13, 2026
integrations#3637 replaced the Optional plus DiffSuppressFunc etag from integrations#3474 with a
plain Computed attribute and CustomizeDiff: diffETag. Move the signing
key resource over, reverting the block added in 0bf03e6, and regenerate
the docs for both resources so etag is listed as read only.
simonostendorf added a commit to simonostendorf/fork-integrations-terraform-provider-github that referenced this pull request Nov 28, 2026
integrations#3637 replaced the Optional plus DiffSuppressFunc etag from integrations#3474 with a
plain Computed attribute and CustomizeDiff: diffETag. Move the signing
key resource over, reverting the block added in 0bf03e6, and regenerate
the docs for both resources so etag is listed as read only.
simonostendorf added a commit to simonostendorf/fork-integrations-terraform-provider-github that referenced this pull request Dec 1, 2026
integrations#3637 replaced the Optional plus DiffSuppressFunc etag from integrations#3474 with a
plain Computed attribute and CustomizeDiff: diffETag. Move the signing
key resource over, reverting the block added in 0bf03e6, and regenerate
the docs for both resources so etag is listed as read only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-github-review Request a review from GitHub Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Legacy etag pattern — Read short-circuits on HTTP 304 and can serve stale state indefinitely (drift never detected)

4 participants