Skip to content

fix: Correct repository environment diff function logic#3469

Open
stevehipwell wants to merge 1 commit into
integrations:mainfrom
stevehipwell:fix-repo-env-diff
Open

fix: Correct repository environment diff function logic#3469
stevehipwell wants to merge 1 commit into
integrations:mainfrom
stevehipwell:fix-repo-env-diff

Conversation

@stevehipwell
Copy link
Copy Markdown
Collaborator

Resolves #3455


Before the change?

  • github_repository_environment with no reviewers couldn't be migrated

After the change?

  • github_repository_environment can be successfully migrated

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
@stevehipwell stevehipwell added this to the v6.13.0 milestone Jun 3, 2026
@stevehipwell stevehipwell requested a review from deiga June 3, 2026 11:39
@stevehipwell stevehipwell self-assigned this Jun 3, 2026
@stevehipwell stevehipwell added the Type: Bug Something isn't working as documented label Jun 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

👋 Hi, and thank you for this contribution!

This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: Could we use more descriptive variable names for this? The code is highly nested and it's really hard to parse what each single char variable is supposed to be.
I don't care how idiomatic for golang this is supposed to be, it's poorly readable code

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

These provider review instructions are being used. This PR fixes a CustomizeDiff panic during upgrades/migrations of github_repository_environment when the prior state has an empty/nil reviewers element, and it updates acceptance coverage around adding/removing reviewers.

Changes:

  • Harden resourceGithubRepositoryEnvironmentDiff to avoid nil/type assertion panics when reviewers is present but not shaped as expected.
  • Adjust the v0 migration schema for reviewers to better match historical state shape during upgrades.
  • Extend acceptance tests to assert expected reviewers list size across updates.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
github/resource_github_repository_environment.go Makes reviewers counting in CustomizeDiff more defensive to prevent panics during plan/upgrade.
github/resource_github_repository_environment_test.go Adds acceptance assertions for reviewers list size across update scenarios.
github/resource_github_repository_environment_migration.go Updates the v0 schema used for state upgrading to align with older reviewers state layout.

Comment on lines 130 to 134
if v, ok := d.GetOk("reviewers"); ok {
count := 0
o := v.([]any)[0]
if t, ok := o.(map[string]any)["teams"]; ok {
count += t.(*schema.Set).Len()
}
if c, ok := v.([]any); ok && len(c) > 0 {
if o, ok := c[0].(map[string]any); ok {
count := 0

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]: github_repository_environment CustomizeDiff panics on nil reviewers after upgrade from v6.11.x to v6.12.x

3 participants