Skip to content

allow empty patterns_allowed in API correctly#3459

Open
deltreey wants to merge 1 commit into
integrations:mainfrom
deltreey:patterns-allowed-fix
Open

allow empty patterns_allowed in API correctly#3459
deltreey wants to merge 1 commit into
integrations:mainfrom
deltreey:patterns-allowed-fix

Conversation

@deltreey
Copy link
Copy Markdown

Resolves #3458


Before the change?

patterns_allowed was omitted when empty in API calls

After the change?

patterns_allowed = [] when empty in API calls

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?

No

Please see our docs on breaking changes to help!

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

These provider review instructions are being used. This PR addresses #3458 by ensuring github_actions_organization_permissions sends an explicit empty patterns_allowed array in the selected-actions update request, since omission can cause GitHub to retain previous allowlist patterns.

Changes:

  • Introduces a provider-local request type and a custom PUT /orgs/{org}/actions/permissions/selected-actions call to control JSON serialization of patterns_allowed.
  • Adds a focused unit test using an httptest server to assert the request includes patterns_allowed: [] when configured empty.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
github/resource_github_actions_organization_permissions.go Adds a custom request type + REST call helper to ensure patterns_allowed can be serialized as [] in selected-actions updates.
github/resource_github_actions_organization_permissions_test.go Adds a unit test that captures and asserts the selected-actions request payload includes patterns_allowed when empty.

Comment on lines +96 to 100
func resourceGithubActionsOrganizationAllowedRequest(d *schema.ResourceData) *actionsAllowedRequest {
allowed := &actionsAllowedRequest{}

config := d.Get("allowed_actions_config").([]any)
if len(config) > 0 {
Comment on lines +249 to +251
resource := resourceGithubActionsOrganizationPermissions()
var selectedActionsPayload map[string]any

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.

@deltreey if you think there is an issue with the go-github implementation please open a PR there to fix it.

FYI you just need to modify PatternsAllowed to omitempty -> omitzero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: github_actions_organization_permissions shouldn't omit empty patterns_allowed for selected Actions policy

3 participants