Skip to content

fix: add nil check for ref_name element in expandConditions#3300

Open
majiayu000 wants to merge 2 commits intointegrations:mainfrom
majiayu000:fix/issue-3299-nil-check-expand-conditions
Open

fix: add nil check for ref_name element in expandConditions#3300
majiayu000 wants to merge 2 commits intointegrations:mainfrom
majiayu000:fix/issue-3299-nil-check-expand-conditions

Conversation

@majiayu000
Copy link

Summary

  • Add v[0] != nil guard to the ref_name condition check in expandConditions (util_rules.go:193) to prevent a panic when ref_name contains a nil element (e.g. org rulesets without ref_name specified)
  • Add unit test TestExpandConditions_NilRefName verifying no panic and nil RefName result

Fixes #3299

Test plan

  • TestExpandConditions_NilRefName passes — confirms no panic on []any{nil} input
  • All existing non-acceptance tests pass (go test ./github/... -skip '^TestAcc')
  • Build passes (go build ./...)

When creating an org ruleset without ref_name specified, Terraform
passes []any{nil} which passes existing length checks but panics
at the type assertion on line 194. Add v[0] != nil guard.

Fixes integrations#3299

Signed-off-by: majiayu000 <1835304752@qq.com>
@github-actions
Copy link

👋 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 Mar 24, 2026
Copy link
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thank you! 🎉

Address review feedback on PR integrations#3300: refactor the single
TestExpandConditions_NilRefName test into a table-driven
TestExpandConditions with broader coverage.

Signed-off-by: majiayu000 <1835304752@qq.com>
@deiga deiga requested a review from stevehipwell March 24, 2026 15:37
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.

[BUG]: Panic in expandConditions when conditions.ref_name is nil/empty

2 participants