Skip to content

fix: Prevent enterprise org taint on SAML enforcement error#3026

Merged
stevehipwell merged 2 commits intointegrations:mainfrom
ericpardee:fix/enterprise-org-saml-create-taint
Jan 15, 2026
Merged

fix: Prevent enterprise org taint on SAML enforcement error#3026
stevehipwell merged 2 commits intointegrations:mainfrom
ericpardee:fix/enterprise-org-saml-create-taint

Conversation

@ericpardee
Copy link
Copy Markdown
Contributor

Resolves #1914


Before the change?

When creating a github_enterprise_organization in an EMU environment, REST API calls fail with SAML enforcement errors until the PAT is authorized for the new org. This affects setting description/display_name during create (and any subsequent updates). The error caused Terraform to taint the resource, leading to destroy+recreate on the next apply.

After the change?

SAML enforcement errors during create/update are now caught and handled gracefully:

  • On create: clears description/display_name from state so it reflects reality
  • On update: resets fields to previous values so state stays accurate
  • Returns success instead of error to prevent tainting
  • Logs a warning instructing the user to authorize the PAT and re-apply

Next plan will show drift and retry after PAT authorization.

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?

  • Yes
  • No

@github-actions
Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@github-actions github-actions bot added the Type: Bug Something isn't working as documented label Dec 27, 2025
@ericpardee
Copy link
Copy Markdown
Contributor Author

Tested manually in EMU environment:

  • terraform apply → org created, SAML error on description/display_name
  • Verified org not tainted, state cleared
  • Authorized PAT
  • terraform plan → no taint, shows drift for description/display_name
  • terraform apply → fields set successfully

@nickfloyd nickfloyd added this to the v6.10.0 Release milestone Jan 8, 2026
Copy link
Copy Markdown
Member

@nickfloyd nickfloyd left a comment

Choose a reason for hiding this comment

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

Just a couple more - post merge.

@ericpardee ericpardee requested a review from nickfloyd January 9, 2026 04:20
@stevehipwell
Copy link
Copy Markdown
Collaborator

@ericpardee could you please rebase this PR?

@ericpardee ericpardee force-pushed the fix/enterprise-org-saml-create-taint branch from 8407e6a to c831293 Compare January 14, 2026 17:27
Copy link
Copy Markdown
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

LGTM

@stevehipwell
Copy link
Copy Markdown
Collaborator

@nickfloyd could you please review this?

ericpardee and others added 2 commits January 15, 2026 15:37
When creating an enterprise organization in an EMU environment, the REST
API call to set description/display_name fails with a SAML enforcement
error until the PAT is authorized for the new org. Previously this would
taint the resource, causing Terraform to destroy and recreate the org on
the next apply.

This fix:
- Catches SAML enforcement errors in Create and Update functions
- Clears description/display_name from state on create, resets to previous
  values on update, so state reflects reality and next plan shows drift
- Returns success instead of error to prevent tainting
- Logs a warning instructing the user to authorize the PAT and re-apply

Fixes: integrations#1914

# Conflicts:
#	github/resource_github_enterprise_organization.go
@stevehipwell stevehipwell force-pushed the fix/enterprise-org-saml-create-taint branch from c831293 to f481cf0 Compare January 15, 2026 15:37
@stevehipwell stevehipwell enabled auto-merge (squash) January 15, 2026 15:37
@stevehipwell stevehipwell merged commit 0271796 into integrations:main Jan 15, 2026
8 checks passed
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

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Approving PAT taints github_enterprise_organization

3 participants