Skip to content

fix: Correct repository environment diff function logic - #3469

Merged
deiga merged 2 commits into
integrations:mainfrom
stevehipwell:fix-repo-env-diff
Jun 5, 2026
Merged

deiga merged 2 commits 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

@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

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

👋 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

@robert-crandall robert-crandall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice fix. Guards in the diff function are clean, and the new test hits the exact regression path. Thanks!

@stevehipwell

Copy link
Copy Markdown
Collaborator Author

@deiga could I please get a re-review?

@deiga
deiga enabled auto-merge (squash) June 5, 2026 09:22
@deiga
deiga merged commit 4349001 into integrations:main Jun 5, 2026
10 checks passed
@stevehipwell
stevehipwell deleted the fix-repo-env-diff branch June 5, 2026 09:27
austenstone pushed a commit to austenstone/terraform-provider-github that referenced this pull request Jun 9, 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.

[BUG]: github_repository_environment CustomizeDiff panics on nil reviewers after upgrade from v6.11.x to v6.12.x

4 participants