Skip to content

Conversation

@deiga
Copy link
Contributor

@deiga deiga commented Dec 26, 2025

Resolves #2988


Before the change?

  • resource_github_repository.go was using Context-unaware functions
  • All errors in updateVulnerabilityAlerts would cause terraform to fail

After the change?

  • resource_github_repository.go is using Context-aware functions
  • Ignore specific 422 response error in updateVulnerabilityAlerts to ensure repo creation works if vulnerability alerts are not modifiable

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

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
In the case of `vulnerability_alerts = false` and the message indicates control from parent Org/Enterprise

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@github-actions
Copy link

👋 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! 🚀

@stevehipwell stevehipwell added this to the v6.9.1 Patch milestone Dec 31, 2025
@stevehipwell stevehipwell added the Type: Bug Something isn't working as documented label Dec 31, 2025
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@deiga deiga requested a review from stevehipwell December 31, 2025 21:15
_, err := updateVulnerabilityAlerts(ctx, owner, repoName)
resp, err := updateVulnerabilityAlertsSDK(ctx, owner, repoName)
if err != nil {
if resp.StatusCode == http.StatusUnprocessableEntity && strings.Contains(err.Error(), "An enforced security configuration prevented modifying") && !ok {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would be a brittle fix, the documented REST API is hard enough to work with so using an error message to control logic isn't something I'd be comfortable doing.

I think the current behaviour is defective given the subsequent GitHub changes. Based on my understanding of d.GetOK() a change like the one I suggested above would only impact new public repos where there is no organization controlled default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did try using d.GetOk() and skipping Delete/Enable with a non-paid Org and private repo. That left the state in a weird state, as vulnerability_alerts was enabled by default and TF had trouble consolidating configuration vs remote state.

I agree that using the error message is problematic, but I can't see any other way to do this with our current limitations.
There are many other cases where a 422 status code shouldn't be ignored, so we can't base it on that either

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually there isn't a good solution for this, even with my pattern the API will be hit every time there is an unrelated repo change. I guess we could remove computed and leave it null if not set, but that is a bigger change. Based on that I think we'll have to go with the error checking logic, but I think we should do the following as part of this PR.

  • Add warning comment in the code that it's a temporary workaround
  • Add issue to track adding a new resource for vulnerability alerts, adding a new ignore_vulnerability_alerts field and deprecating vulnerability_alerts & ignore_vulnerability_alerts_during_read for v6.10.0
  • Add issue to track removal of ignore_vulnerability_alerts, vulnerability_alerts & ignore_vulnerability_alerts_during_read for v7.0.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevehipwell Done!

I've added #3038 and #3039 could you assign them to correct milestones?

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
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]: creation of github_repository fails from v6.7.0 onwards

2 participants