Skip to content

[BUG] Ensure autolink reference doesn't error when repo is renamed - #3271

Open
deiga wants to merge 19 commits into
integrations:mainfrom
F-Secure-web:ensure-autolinks-are-aware-of-repo-rename
Open

[BUG] Ensure autolink reference doesn't error when repo is renamed#3271
deiga wants to merge 19 commits into
integrations:mainfrom
F-Secure-web:ensure-autolinks-are-aware-of-repo-rename

Conversation

@deiga

@deiga deiga commented Mar 12, 2026

Copy link
Copy Markdown
Collaborator

Resolves #3470


Before the change?

  • Renaming a repository caused an existing github_repository_autolink_reference to be re-created and throw an error

After the change?

  • Renaming a repository does not cause an error in github_repository_autolink_reference

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

@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! 🚀

@deiga deiga added this to the v6.12.0 Release milestone Mar 15, 2026
@deiga
deiga requested a review from stevehipwell March 15, 2026 16:51
@deiga
deiga force-pushed the ensure-autolinks-are-aware-of-repo-rename branch from ad1fdb7 to 00ea1c8 Compare April 18, 2026 18:34
@deiga deiga added the Type: Bug Something isn't working as documented label Apr 18, 2026
@deiga
deiga force-pushed the ensure-autolinks-are-aware-of-repo-rename branch from 00ea1c8 to 458f672 Compare May 11, 2026 02:13
@deiga
deiga marked this pull request as draft May 14, 2026 21:09

@stevehipwell stevehipwell left a comment

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.

Do we need a migration to add the repository ID and then rely on it or we just supporting it as a best effort?

Comment thread github/resource_github_repository_autolink_reference.go
@deiga deiga removed this from the v6.13.0 milestone Jun 3, 2026
@deiga
deiga force-pushed the ensure-autolinks-are-aware-of-repo-rename branch from 458f672 to 852d646 Compare June 6, 2026 05:29
@deiga
deiga force-pushed the ensure-autolinks-are-aware-of-repo-rename branch from 852d646 to 50a9aa7 Compare July 9, 2026 18:29
@deiga
deiga marked this pull request as ready for review July 9, 2026 18:29
@deiga
deiga requested a review from Copilot July 9, 2026 18:30

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 #3470 for github_repository_autolink_reference so that renaming a repository no longer forces the autolink reference to be destroyed and recreated (which previously errored). It adopts the provider's rename-safe convention: drop ForceNew from repository, add a computed repository_id, and wire up CustomizeDiff: diffRepository so replacement is only forced when the underlying repository ID actually changes. The CRUD handlers are also modernized to the *Context variants, and a state upgrader is added to backfill repository_id.

Changes:

  • Convert CRUD to context-aware handlers, add a no-op Update, extract the importer, and switch logging to tflog.
  • Add repository_id (computed), remove ForceNew from repository, and add CustomizeDiff: diffRepository; add a state upgrader + migration to populate repository_id.
  • Update acceptance tests to statecheck/plancheck (incl. a rename scenario), add a migration unit test, and refresh docs/example.

Reviewed changes

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

Show a summary per file
File Description
github/resource_github_repository_autolink_reference.go Rename-safe schema (repository_id, no ForceNew, diffRepository), context CRUD, no-op Update; state upgrader registered with a version mismatch (blocking).
github/resource_github_repository_autolink_reference_migration.go New V0 schema + state upgrade func that fetches and stores repository_id.
github/resource_github_repository_autolink_reference_migration_test.go Unit test invoking the state upgrade function directly against a mocked API.
github/resource_github_repository_autolink_reference_test.go Migrates checks to statecheck, adds a repository-rename in-place test.
templates/resources/repository_autolink_reference.md.tmpl Docs template: updated repository description, adds repository_id.
docs/resources/repository_autolink_reference.md Generated docs mirror the template/schema updates and visibility example.
examples/resources/repository_autolink_reference/example_1.tf Example switched from deprecated private to visibility.

Blocking finding: the added StateUpgrader uses Version: 0 while the resource already ships at SchemaVersion: 1, so it will never execute for existing state (which is already stamped v1). The version must be bumped to 2 with the upgrader registered at Version: 1 to actually backfill repository_id.

Comment thread github/resource_github_repository_autolink_reference.go Outdated
@deiga
deiga requested a review from stevehipwell July 9, 2026 18:42
@deiga
deiga force-pushed the ensure-autolinks-are-aware-of-repo-rename branch from cf7ee3b to 4b95c1a Compare July 10, 2026 09:01

@stevehipwell stevehipwell left a comment

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.

Just a quick review.

Comment thread RESOURCES.md Outdated
Comment thread github/resource_github_repository_autolink_reference.go
Comment thread github/resource_github_repository_autolink_reference.go
Comment thread github/resource_github_repository_autolink_reference.go Outdated
Comment on lines +207 to +210
parts := strings.Split(d.Id(), "/")
if len(parts) != 2 {
return nil, fmt.Errorf("invalid ID specified: supplied ID must be written as <repository>/<autolink_reference_id>")
}

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.

I think the ID should be migrated as part of the schema migration so it can use the ID functions.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Since this is "just" the import ID, it doesn't need a migration, right?

@deiga
deiga force-pushed the ensure-autolinks-are-aware-of-repo-rename branch from 4b95c1a to aaa15da Compare July 14, 2026 19:55
Comment thread github/resource_github_repository_autolink_reference.go Outdated
Comment thread github/resource_github_repository_autolink_reference.go Outdated
Comment thread github/resource_github_repository_autolink_reference.go Outdated
Comment thread github/resource_github_repository_autolink_reference.go Outdated
Comment thread github/resource_github_repository_autolink_reference.go Outdated
Comment thread github/resource_github_repository_autolink_reference.go
Comment thread github/resource_github_repository_autolink_reference_migration.go Outdated
Comment thread github/resource_github_repository_autolink_reference_migration_test.go Outdated
Comment thread github/resource_github_repository_autolink_reference_test.go Outdated
Comment thread github/resource_github_repository_autolink_reference_test.go
@deiga
deiga force-pushed the ensure-autolinks-are-aware-of-repo-rename branch from aaa15da to ba732c3 Compare July 22, 2026 19:21
@deiga
deiga force-pushed the ensure-autolinks-are-aware-of-repo-rename branch from ba732c3 to a66eaa4 Compare August 3, 2026 18:24
@deiga
deiga requested a review from stevehipwell August 3, 2026 18:24
deiga added 5 commits August 22, 2026 14:13
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
deiga added 6 commits August 22, 2026 14:13
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@deiga deiga added the vNext label Aug 22, 2026
deiga added 8 commits August 22, 2026 14:13
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@deiga
deiga force-pushed the ensure-autolinks-are-aware-of-repo-rename branch from a66eaa4 to f1c9742 Compare August 22, 2026 11:15
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 vNext

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resource_github_repository_autolink_reference.go — github_repository_autolink_reference (field: repository)

3 participants