allow empty patterns_allowed in API correctly#3459
Conversation
|
👋 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 |
There was a problem hiding this comment.
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-actionscall to control JSON serialization ofpatterns_allowed. - Adds a focused unit test using an
httptestserver to assert the request includespatterns_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. |
| func resourceGithubActionsOrganizationAllowedRequest(d *schema.ResourceData) *actionsAllowedRequest { | ||
| allowed := &actionsAllowedRequest{} | ||
|
|
||
| config := d.Get("allowed_actions_config").([]any) | ||
| if len(config) > 0 { |
| resource := resourceGithubActionsOrganizationPermissions() | ||
| var selectedActionsPayload map[string]any | ||
|
|
There was a problem hiding this comment.
@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.
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
Does this introduce a breaking change?
No
Please see our docs on breaking changes to help!