Skip to content

feat: Adds DiffSuppressFunc and DiffSuppressOnRefresh to resources that have etag properties to suppress etag-related diffs - #2840

Merged
nickfloyd merged 5 commits into
mainfrom
796/suppress-etag-diffs
Oct 29, 2025
Merged

nickfloyd merged 5 commits into
mainfrom
796/suppress-etag-diffs

Conversation

@nickfloyd

@nickfloyd nickfloyd commented Oct 29, 2025 •

Copy link
Copy Markdown
Contributor

Resolves #796


Before the change?

  • Prior to this change the provider would detect etag diff changes

After the change?

  • After a successful terraform apply, terraform plan or terraform apply detects no changes.

Details from #796

Initially an approach was made but the implementation was incomplete due to needing to support update. 4 years later we're on a newer version of the SDK (terraform-plugin-sdk/v2 v2.34.0) that supports DiffSuppressOnRefresh

We should now be able to go with the initial approach (even on computed fields) of:

DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
    return true
},

And add DiffSuppressOnRefresh: true as well to suppress the diff between config and state.

Lastly these fields have to be marked as optional=true - SDK ref

Computed-only fields: Computed: true, Optional: false → Can't have DiffSuppressFunc
Optional computed fields: Computed: true, Optional: true → Can have DiffSuppressFunc

I believe we can set this to always returns true - which should suppress all etag diffs; this should also work for refresh operations as well.

This approach should be safe because ETags are internal concerns, not user configuration, ETags are still stored and used for API optimization by the SDK / provider, and all user changes to actual resource attributes are still detected normally.

Let me put a quick PR together to illustrate this and see if everyone agrees with the approach. The better move would be to migrate to the Plugin Framework but for now we can get this cleaned up a bit as is.

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

…e etag properties to suppress etag-related diffs
@nickfloyd nickfloyd self-assigned this Oct 29, 2025
@nickfloyd nickfloyd added the Type: Bug Something isn't working as documented label Oct 29, 2025
@nickfloyd nickfloyd moved this from Backlog to In Progress in Terraform Provider Oct 29, 2025

@usmonster usmonster 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.

✅ LTGM (though I have no authority here 😄)

@nickfloyd nickfloyd moved this from In Progress to In Review in Terraform Provider Oct 29, 2025
@nickfloyd nickfloyd changed the title Adds DiffSuppressFunc and DiffSuppressOnRefresh to resources that have etag properties to suppress etag-related diffs feat: Adds DiffSuppressFunc and DiffSuppressOnRefresh to resources that have etag properties to suppress etag-related diffs Oct 29, 2025
@nickfloyd
nickfloyd merged commit 17da14c into main Oct 29, 2025
@nickfloyd
nickfloyd deleted the 796/suppress-etag-diffs branch October 29, 2025 18:42
@github-project-automation github-project-automation Bot moved this from In Review to Done in Terraform Provider Oct 29, 2025
@Wirone

Wirone commented Feb 11, 2026 •

Copy link
Copy Markdown

Sorry for digging old PRs, but we struggle with this in our PR automation.

Installed integrations/github v6.11.0 (signed by a HashiCorp partner, key ID 38027F80D7FD5FB2)

Even though we're using 6.11, we see a lot etag changes for github_team resources in the output, which makes it cumbersome to find actual changes in the Atlantis plan's output. What can be the reason?

@deiga

deiga commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator

@Wirone Could you share DEBUG logs of a plan to help us narrow it down?

@Wirone

Wirone commented Feb 11, 2026

Copy link
Copy Markdown

@deiga it's in our company's proprietary project for IaaC, so it may be hard to share it as it contains a lot of information about the infra even in INFO mode... But in short: today I added 6 github_actions_organization_variable/ github_actions_organization_secret resources and the Atlantis plan's output was so long (because of etag stuff) that it reached Github's comment's length limit and had to be split in two, with the info I was interested in at the very end of it 🤷. We live with it, but it's pretty overwhelming.

@deiga

deiga commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator

@deiga it's in our company's proprietary project for IaaC, so it may be hard to share it as it contains a lot of information about the infra even in INFO mode... But in short: today I added 6 github_actions_organization_variable/ github_actions_organization_secret resources and the Atlantis plan's output was so long (because of etag stuff) that it reached Github's comment's length limit and had to be split in two, with the info I was interested in at the very end of it 🤷. We live with it, but it's pretty overwhelming.

@Wirone i get that it can be daunting to share something.
I'm not asking for a full log, you're free to redact it. The thing is, you're the first in a long while reporting this and we don't have a clue on why it wouldn't work.

Would you be able to use targeting to only one of these resources on DEBUG level? That could be enough to follow where the code is going.
And feel free to obfuscate anything that could be sensitive ☺️

@Wirone

Wirone commented Feb 11, 2026

Copy link
Copy Markdown

I will try to do it 👍.

@caulagi caulagi mentioned this pull request Mar 19, 2026
1 task done
ei-grad added a commit to ei-grad/terraform-provider-github that referenced this pull request Mar 30, 2026
… fields

PR integrations#2840 added etag diff suppression to 7 resources but missed the
remaining 22. This causes spurious diffs on every plan/apply for
resources like github_team, github_membership, github_team_repository,
github_repository_deploy_key, and others.

Apply the same pattern (Optional + DiffSuppressFunc returning true +
DiffSuppressOnRefresh) to all remaining resource etag schema fields
and extend the unit test to cover all 29 resources.

Fixes integrations#3103
Fixes integrations#3291

Co-Authored-By: Claude <[email protected]>
ei-grad added a commit to ei-grad/terraform-provider-github that referenced this pull request Apr 1, 2026
etag is server-computed and should not be user-editable. Remove
Optional: true from all etag schema fields (both the 22 new ones
and the 7 from PR integrations#2840) and update the unit test accordingly.

Co-Authored-By: Claude <[email protected]>
@stevehipwell stevehipwell mentioned this pull request Sep 9, 2026
4 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

Development

Successfully merging this pull request may close these issues.

continual changes detected due to changing etag

4 participants