Repository navigation
Closed
Labels
Milestone
Description
Expected Behavior
The provider should send the equivalent of:
{
enabled_repositories": "none"
}
GitHub Actions should be disabled for all repositories in the organization.
Actual Behavior
Terraform plans successfully:
+ resource "github_actions_organization_permissions" "test" {
+ enabled_repositories = "none"
+ id = (known after apply)
+ sha_pinning_required = (known after apply)
}
Apply fails:
Error: PUT https://api.example.ghe.com/orgs/example-org/actions/permissions: 422 Invalid request.
is not a member of ["all", "local_only", "selected"].
That validation error appears to refer to allowed_actions, not enabled_repositories.
Terraform Version
Terraform v1.15.0
on darwin_arm64
- provider registry.terraform.io/integrations/github v6.12.1
Affected Resource(s)
- github_actions_organization_permissions
Terraform Configuration Files
terraform {
required_providers {
github = {
source = "integrations/github"
version = "6.12.1"
}
}
}
provider "github" {
owner = "example-org"
base_url = "https://api.example.ghe.com/"
token = var.github_token
}
variable "github_token" {
type = string
sensitive = true
}
with this setup:
resource "github_actions_organization_permissions" "test" {
enabled_repositories = "none"
}
Notably, these others also fail
resource "github_actions_organization_permissions" "test" {
enabled_repositories = "none"
allowed_actions = "all"
}
resource "github_actions_organization_permissions" "test" {
enabled_repositories = "none"
allowed_actions = "local_only"
}
resource "github_actions_organization_permissions" "test" {
enabled_repositories = "none"
allowed_actions = "selected"
allowed_actions_config {
github_owned_allowed = false
verified_allowed = false
patterns_allowed = []
}
}
and even
resource "github_actions_organization_permissions" "test" {
enabled_repositories = "none"
allowed_actions = "selected"
allowed_actions_config {
github_owned_allowed = false
verified_allowed = false
patterns_allowed = ["actions/checkout@*"]
}
}Steps to Reproduce
TF_VAR_github_token="<token>" terraform apply
Debug Output
I actually did more research than the above.
In `github/resource_github_actions_organization_permissions.go`, the provider always sets AllowedActions, even when allowed_actions is omitted:
allowedActions := d.Get("allowed_actions").(string)
enabledRepositories := d.Get("enabled_repositories").(string)
actionsPermissions := github.ActionsPermissions{
AllowedActions: &allowedActions,
EnabledRepositories: &enabledRepositories,
}
Because allowed_actions is optional, d.Get("allowed_actions").(string) returns "" when omitted. The provider then appears to send allowed_actions: "", which GitHub rejects because valid values are only all, local_only, and selected.
This differs from the nearby repository-level Actions permissions resource, which avoids sending allowed_actions when Actions are disabled:
allowedActions := d.Get("allowed_actions").(string)
enabled := d.Get("enabled").(bool)
repoActionPermissions := github.ActionsPermissionsRepository{
Enabled: &enabled,
}
// Only specify `allowed_actions` if actions are enabled
if enabled {
repoActionPermissions.AllowedActions = &allowedActions
}
That pattern seems appropriate for organization-level permissions too. When enabled_repositories = "none", allowed_actions should not be sent unless the API explicitly requires it.
The provider also uses GetOk / non-empty checks elsewhere for optional string fields, for example:
if v, ok := d.GetOk("description"); ok && len(v.(string)) > 0 {
milestone.Description = new(v.(string))
}
And this path is entirely untested. Current acceptance tests appear to cover:
enabled_repositories = "all"
enabled_repositories = "selected" with non-empty repository IDs
selected allowed-actions config
They do not appear to cover:
enabled_repositories = "none"
enabled_repositories = "selected" with repository_ids = []
Those two cases are important for deny-by-default organization baselines.
I tested this code change locally with Terraform provider development overrides, and it fixes the problem.
This configuration now applies successfully and immediately converges:
resource "github_actions_organization_permissions" "test" {
enabled_repositories = "none"
}
Observed API response after apply:
{"enabled_repositories":"none","sha_pinning_required":false}
Follow-up terraform plan result:
No changes. Your infrastructure matches the configuration.
This configuration also applies successfully and immediately converges:
resource "github_actions_organization_permissions" "test" {
enabled_repositories = "selected"
allowed_actions = "local_only"
enabled_repositories_config {
repository_ids = []
}
}
Observed API response after apply:
{
"enabled_repositories": "selected",
"allowed_actions": "local_only"
}
Observed selected repository list after apply:
{"total_count":0,"repositories":[]}
Follow-up terraform plan result:
No changes. Your infrastructure matches the configuration.
Sketch:
func resourceGithubActionsEnabledRepositoriesObject(d *schema.ResourceData) ([]int64, error) {
config := d.Get("enabled_repositories_config").([]any)
if len(config) == 0 || config[0] == nil {
return []int64{}, nil
}
data, ok := config[0].(map[string]any)
if !ok {
return []int64{}, nil
}
ids, ok := data["repository_ids"].(*schema.Set)
if !ok || ids == nil {
return []int64{}, nil
}
enabled := make([]int64, 0, ids.Len())
for _, value := range ids.List() {
enabled = append(enabled, int64(value.(int)))
}
return enabled, nil
}Panic Output
Code of Conduct
- I agree to follow this project's Code of Conduct
Reacted by Willy
Activity
github-actions commentedon May 11, 2026
👋 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! 🚀deltreey commentedon May 26, 2026
I literally have a fix for this, documented in this issue. This should be trivial to close.
deiga commentedon May 26, 2026
@deltreey many things are trivial to close, but it is not trivial to find time for everything, unfortunately.
While we appreciate the effort you put into investigating this, you did not fully fill out the issue template and we're missing crucial information like the Debug-level logs. Could you extract your solution proposal into a comment, so that it's easier to read?
deltreey commentedon May 28, 2026
did that with a PR
3rwww1 commentedon Sep 21, 2026
Confirming on GitHub.com (not GHES) with provider v6.13.0, Terraform 1.16.3, running on Terraform Cloud remote workers. Same root cause as described above: the update path always sends
allowed_actions, soenabled_repositories = "none"cannot be written.Repro 1 -
nonealonePlan is clean, apply fails. On GitHub.com the API answers 409 with an empty body instead of the 422 seen on GHES:
Repro 2 - the documented alternative also fails
Trying to express "off" as
selectedwith zero repositories crashes the provider:Terraform reports it as
Plugin did not respond. This is the second gap in the issue description (emptyrepository_ids), also covered by #3457.Workaround we use until #3457 ships
Disable Actions out of band, with no other key in the body. Returns 204:
Keep the resource in config with
enabled_repositories = "none"andallowed_actionsomitted. The GET response dropsallowed_actionswhen Actions are off, the provider reads it back as"", and the plan is a no-op. Drift is still detected; re-applying it needs the hand PUT again.Reads are fine, only the transition PUT is broken. +1 for merging #3457, the fix is small and this blocks deny-by-default org baselines.