Skip to content

fix(custom-property): return error for empty property_value instead of panicking#3366

Open
SAY-5 wants to merge 1 commit intointegrations:mainfrom
SAY-5:fix/custom-property-empty-value-panic-3358
Open

fix(custom-property): return error for empty property_value instead of panicking#3366
SAY-5 wants to merge 1 commit intointegrations:mainfrom
SAY-5:fix/custom-property-empty-value-panic-3358

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 23, 2026

Refs #3358.

Problem

resourceGithubRepositoryCustomPropertyCreate unconditionally accessed propertyValue[0] for scalar property_type values (string, single_select, url, true_false). Terraform / OpenTofu plans that resolve property_value to an empty list — either explicitly or via a computed source — crashed the provider with:

panic: runtime error: index out of range [0] with length 0
resourceGithubRepositoryCustomPropertyCreate
  github/resource_github_repository_custom_property.go:72 +0x698

OpenTofu surfaces this as a plugin crash rather than a configuration error, leaving resource state dangling.

Fix

Guard the index with an explicit length check that returns a clear Terraform error naming the offending property_type. multi_select is unaffected — an empty slice there is intentionally allowed.

Test

go build ./... clean. Behavior on non-empty values is unchanged; the previous panic path now returns a descriptive error.

…f panicking

resource_github_repository_custom_property.go:72 unconditionally
dereferenced propertyValue[0] for scalar property_type values
(string, single_select, url, true_false). Terraform configurations
that supplied property_value as an empty list — or where a computed
value resolved to empty at apply time — crashed the provider with:

    panic: runtime error: index out of range [0] with length 0
    resourceGithubRepositoryCustomPropertyCreate ... +0x698

OpenTofu / Terraform recovers from this as a plugin crash, leaves
dangling resource state, and reports it as an internal provider
error rather than a user-facing configuration error.

Guard the index with an explicit length check that returns a clear
Terraform error naming the offending property_type. Multi_select is
unaffected — an empty slice there is intentionally allowed.

Refs integrations/terraform-provider-github issue 3358.
@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! 🚀

@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant