integrations / integrations/terraform-provider-github

[BUG]: 409 response when destroying github_actions_repository_permissions

Open
#2,681 2 comments 9 reactions 0 assignees View on GitHub
r/actions_repository_permissions Status: Needs info Type: Bug
Dominant language
Go
Stars
1.2k
Forks
1k
Avg merge
1d 14h
Merged PRs (30d)
8

Description

### Expected Behavior

When destroying a `github_actions_repository_permissions` resource, the provider should do so in a compliant way as to not result in an error when Actions permissions / policies are enforced at the Enterprise or Organization level.

### Actual Behavior

The provider throws `Error: PUT https://ndia.ghe.com/api/v3/repos///actions/permissions: 409 []` when attempting to delete the resource.

Taking a look at the [API docs](https://docs.github.com/en/rest/actions/permissions?apiVersion=2022-11-28#set-default-workflow-permissions-for-a-repository--status-codes), this is expected behaviour when there is a conflict in overarching settings enforced by the Organization (or Enterprise in our case).

Looking at the [source](https://github.com/integrations/terraform-provider-github/blob/6008909a212294e332cb23f3bbaf1089e0d9ed1e/github/resource_github_actions_repository_permissions.go#L226) for the delete of this resource, it assumes what the default settings should be to return to - which are invalid for us.

### Terraform Version

Terraform v1.12.1
on darwin_arm64
+ provider registry.terraform.io/integrations/github v6.6.0

### Affected Resource(s)

- github_actions_repository_permissions

### Terraform Configuration Files

```hcl
resource "github_actions_repository_permissions" "default" {
repository = github_repository.default.name
enabled = var.actions # In this scenario, this is true.
allowed_actions = var.actions ? "selected" : null # This is managed at the enterprise level
}
```

### Steps to Reproduce

```
terraform apply
terraform destroy
```

### Debug Output

```shell

```

### Panic Output

```shell

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.