Skip to content

Conversation

@steveteuber
Copy link
Contributor

This is a follow-up pull request to fix the issue described in #2077.


Before the change?

There is a bug in the GitHub API 2022-11-28 version that causes a 422 error when updating a repository within an organization that has "Require sign off on web-based commits" enabled.

After the change?

On a repository update, we check if the organization has "Require sign off on web-based commits" enabled.
If it's enabled, we do not send the web_commit_signoff_required field in the update request to avoid the 422 error.

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

@ArlonAntonius
Copy link

Hi @steveteuber,

I was reading into this issue and was wondering the following:
At this moment only changes to the update method have been provided, does that mean that this issue does not seem to happen on the creation of a GitHub repository?

@steveteuber
Copy link
Contributor Author

@ArlonAntonius Yes, correct. After #2763 was merged, this issue now occurs only when updating a repository.

@nickfloyd nickfloyd moved this from Backlog to In Review in Terraform Provider Nov 19, 2025
Copy link
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.

Let me know what you think about my comment and thank you for this change ❤️

// When the organization has "Require contributors to sign off on web-based commits" enabled,
// the API doesn't allow you to send `web_commit_signoff_required` or it returns a 422 error.
// As a workaround, check if the organization requires it, and if so, remove it from the request.
if meta.(*Owner).IsOrganization && meta.(*Owner).IsWebCommitSignoffRequired {
Copy link
Member

Choose a reason for hiding this comment

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

I think removing the d.HasChange("web_commit_signoff_required") conditional might be problematic. This change might cause issues when archiving repositories in organizations that don't have signoff required but the repository itself has it set, potentially causing a 422. Check me on that though.

repoReq := resourceGithubRepositoryObject(d)
// Always remove `web_commit_signoff_required` when archiving, to avoid 422 error
repoReq.WebCommitSignoffRequired = nil
if meta.(*Owner).IsOrganization && meta.(*Owner).IsWebCommitSignoffRequired {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

@nickfloyd nickfloyd moved this from In Review to BLOCKED in Terraform Provider Nov 19, 2025
@nickfloyd nickfloyd added the Type: Bug Something isn't working as documented label Nov 19, 2025
@nickfloyd nickfloyd added this to the v7 Next milestone Nov 20, 2025
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

Status: BLOCKED

Development

Successfully merging this pull request may close these issues.

3 participants