Description
When using github_repository_ruleset with the pull_request.required_reviewers block, the resource creation POST to the GitHub API succeeds, but the provider fails to deserialize the response because reviewer.id is returned as a JSON string by the API while the Go struct expects int64.
Error
sdk-v2/provider2.go:572: sdk.helper_schema: json: cannot unmarshal string into Go struct field RepositoryRuleset.rules.required_reviewers.reviewer.id of type int64
Terraform / Provider Version
- terraform-provider-github: v6.6.0 (also reproduced via Pulumi bridged provider @pulumi/github 6.12.1 which bundles terraform-provider-github v6.11.1)
Resource Configuration (minimal reproduction)
resource "github_repository_ruleset" "example" {
name = "reviewer-requirements"
repository = "my-repo"
target = "branch"
enforcement = "active"
conditions {
ref_name {
include = ["~DEFAULT_BRANCH"]
exclude = []
}
}
rules {
pull_request {
required_approving_review_count = 0
required_reviewers {
file_patterns = ["src/migrations/**"]
minimum_approvals = 1
reviewer {
id = data.github_team.my_team.id
type = "Team"
}
}
}
}
}
data "github_team" "my_team" {
slug = "my-team"
}
What Happens
- The provider successfully POSTs to
POST /repos/{owner}/{repo}/rulesets — the ruleset is created in GitHub.
- The GitHub API returns a JSON response where
reviewer.id is a string (e.g., "12345678").
- The Go provider attempts to unmarshal this into a struct field typed as
int64.
- Deserialization fails with the error above.
- Because the provider can't parse the response, the resource is not recorded in state — but it does exist in GitHub. This creates an orphaned resource on every retry.
Expected Behavior
The provider should handle the reviewer.id field being returned as a string by the GitHub API and coerce it to int64 (e.g., via json.Number or a custom unmarshaler), since the API consistently returns numeric IDs as JSON strings in this response.
Additional Context
- The
required_reviewers feature is noted as beta in the provider SDK.
- The
bypass_actors[].actor_id field handles the same string-from-API pattern correctly — it's only required_reviewers[].reviewer.id that fails.
- The orphaned-resource behavior (ruleset created in GitHub but not in state) makes this particularly disruptive, as subsequent applies fail with "Name must be unique" until the orphan is manually deleted via the API.
Description
When using
github_repository_rulesetwith thepull_request.required_reviewersblock, the resource creation POST to the GitHub API succeeds, but the provider fails to deserialize the response becausereviewer.idis returned as a JSON string by the API while the Go struct expectsint64.Error
Terraform / Provider Version
Resource Configuration (minimal reproduction)
What Happens
POST /repos/{owner}/{repo}/rulesets— the ruleset is created in GitHub.reviewer.idis a string (e.g.,"12345678").int64.Expected Behavior
The provider should handle the
reviewer.idfield being returned as a string by the GitHub API and coerce it to int64 (e.g., viajson.Numberor a custom unmarshaler), since the API consistently returns numeric IDs as JSON strings in this response.Additional Context
required_reviewersfeature is noted as beta in the provider SDK.bypass_actors[].actor_idfield handles the same string-from-API pattern correctly — it's onlyrequired_reviewers[].reviewer.idthat fails.