Skip to content

fix: error if autolink reference not found#2164

Merged
kfcampbell merged 5 commits intointegrations:mainfrom
bradam12:fix-invalid-autolink-ref-import
Mar 8, 2024
Merged

fix: error if autolink reference not found#2164
kfcampbell merged 5 commits intointegrations:mainfrom
bradam12:fix-invalid-autolink-ref-import

Conversation

@bradam12
Copy link
Copy Markdown
Contributor

@bradam12 bradam12 commented Feb 20, 2024

Resolves #2163


Before the change?

  • panic when importing invalid autolink reference

After the change?

  • throws an error as expected

Pull request checklist

  • 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

@kfcampbell
Copy link
Copy Markdown
Contributor

Would it be possible to write a test for this case? Could you also describe how you've manually tested this scenario?

@bradam12
Copy link
Copy Markdown
Contributor Author

bradam12 commented Mar 4, 2024

Yeah I can whip up a test in the next day or so.

I built the provider locally and used it with our GHES instance with a TF_CLI_CONFIG_FILE envvar.

@bradam12
Copy link
Copy Markdown
Contributor Author

bradam12 commented Mar 5, 2024

GITHUB_BASE_URL=https://ourgithub.int GITHUB_TOKEN=redacted GITHUB_ORGANIZATION=test GITHUB_OWNER=test TF_ACC=1 go test -v ./... -run ^TestAccGithubRepositoryAutolinkReference
?       github.com/integrations/terraform-provider-github/v6    [no test files]
=== RUN   TestAccGithubRepositoryAutolinkReferencesDataSource
=== RUN   TestAccGithubRepositoryAutolinkReferencesDataSource/queries_autolink_references
=== RUN   TestAccGithubRepositoryAutolinkReferencesDataSource/queries_autolink_references/with_an_anonymous_account
    data_source_github_repository_autolink_references_test.go:61: anonymous account not supported for this operation
=== RUN   TestAccGithubRepositoryAutolinkReferencesDataSource/queries_autolink_references/with_an_individual_account
=== RUN   TestAccGithubRepositoryAutolinkReferencesDataSource/queries_autolink_references/with_an_organization_account
--- PASS: TestAccGithubRepositoryAutolinkReferencesDataSource (36.15s)
    --- PASS: TestAccGithubRepositoryAutolinkReferencesDataSource/queries_autolink_references (36.15s)
        --- SKIP: TestAccGithubRepositoryAutolinkReferencesDataSource/queries_autolink_references/with_an_anonymous_account (0.00s)
        --- PASS: TestAccGithubRepositoryAutolinkReferencesDataSource/queries_autolink_references/with_an_individual_account (18.16s)
        --- PASS: TestAccGithubRepositoryAutolinkReferencesDataSource/queries_autolink_references/with_an_organization_account (17.99s)
=== RUN   TestAccGithubRepositoryAutolinkReference
=== RUN   TestAccGithubRepositoryAutolinkReference/creates_repository_autolink_reference_without_error
=== RUN   TestAccGithubRepositoryAutolinkReference/creates_repository_autolink_reference_without_error/with_an_anonymous_account
    resource_github_repository_autolink_reference_test.go:113: anonymous account not supported for this operation
=== RUN   TestAccGithubRepositoryAutolinkReference/creates_repository_autolink_reference_without_error/with_an_individual_account
=== RUN   TestAccGithubRepositoryAutolinkReference/creates_repository_autolink_reference_without_error/with_an_organization_account
=== RUN   TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_without_error
=== RUN   TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_without_error/with_an_anonymous_account
    resource_github_repository_autolink_reference_test.go:251: anonymous account not supported for this operation
=== RUN   TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_without_error/with_an_individual_account
=== RUN   TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_without_error/with_an_organization_account
=== RUN   TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_by_key_prefix_without_error
=== RUN   TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_by_key_prefix_without_error/with_an_anonymous_account
    resource_github_repository_autolink_reference_test.go:306: anonymous account not supported for this operation
=== RUN   TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_by_key_prefix_without_error/with_an_individual_account
=== RUN   TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_by_key_prefix_without_error/with_an_organization_account
=== RUN   TestAccGithubRepositoryAutolinkReference/deletes_repository_autolink_reference_without_error
=== RUN   TestAccGithubRepositoryAutolinkReference/deletes_repository_autolink_reference_without_error/with_an_anonymous_account
    resource_github_repository_autolink_reference_test.go:350: anonymous account not supported for this operation
=== RUN   TestAccGithubRepositoryAutolinkReference/deletes_repository_autolink_reference_without_error/with_an_individual_account
=== RUN   TestAccGithubRepositoryAutolinkReference/deletes_repository_autolink_reference_without_error/with_an_organization_account
--- PASS: TestAccGithubRepositoryAutolinkReference (143.88s)
    --- PASS: TestAccGithubRepositoryAutolinkReference/creates_repository_autolink_reference_without_error (40.45s)
        --- SKIP: TestAccGithubRepositoryAutolinkReference/creates_repository_autolink_reference_without_error/with_an_anonymous_account (0.00s)
        --- PASS: TestAccGithubRepositoryAutolinkReference/creates_repository_autolink_reference_without_error/with_an_individual_account (20.16s)
        --- PASS: TestAccGithubRepositoryAutolinkReference/creates_repository_autolink_reference_without_error/with_an_organization_account (20.29s)
    --- PASS: TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_without_error (55.88s)
        --- SKIP: TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_without_error/with_an_anonymous_account (0.00s)
        --- PASS: TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_without_error/with_an_individual_account (27.41s)
        --- PASS: TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_without_error/with_an_organization_account (28.47s)
    --- PASS: TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_by_key_prefix_without_error (35.35s)
        --- SKIP: TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_by_key_prefix_without_error/with_an_anonymous_account (0.00s)
        --- PASS: TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_by_key_prefix_without_error/with_an_individual_account (16.89s)
        --- PASS: TestAccGithubRepositoryAutolinkReference/imports_repository_autolink_reference_by_key_prefix_without_error/with_an_organization_account (18.46s)
    --- PASS: TestAccGithubRepositoryAutolinkReference/deletes_repository_autolink_reference_without_error (12.20s)
        --- SKIP: TestAccGithubRepositoryAutolinkReference/deletes_repository_autolink_reference_without_error/with_an_anonymous_account (0.00s)
        --- PASS: TestAccGithubRepositoryAutolinkReference/deletes_repository_autolink_reference_without_error/with_an_individual_account (6.15s)
        --- PASS: TestAccGithubRepositoryAutolinkReference/deletes_repository_autolink_reference_without_error/with_an_organization_account (6.04s)
PASS
ok      github.com/integrations/terraform-provider-github/v6/github     180.140s

Copy link
Copy Markdown
Contributor

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

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

Thank you! Confirming tests pass for me as well (pointed toward github.com).

@kfcampbell kfcampbell merged commit 4cebab8 into integrations:main Mar 8, 2024
kireque referenced this pull request in kireque/home-ops-old Mar 22, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github](https://registry.terraform.io/providers/integrations/github)
([source](https://togithub.com/integrations/terraform-provider-github))
| required_provider | minor | `6.0.1` -> `6.2.0` |

---

### Release Notes

<details>
<summary>integrations/terraform-provider-github (github)</summary>

###
[`v6.2.0`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v6.2.0)

[Compare
Source](https://togithub.com/integrations/terraform-provider-github/compare/v6.1.0...v6.2.0)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Features

- feat: add `github_enterprise_actions_runner_group` by
[@&#8203;bradam12](https://togithub.com/bradam12) in
[https://github.com/integrations/terraform-provider-github/pull/2158](https://togithub.com/integrations/terraform-provider-github/pull/2158)
- Feat: Fixes abandoned PR
[#&#8203;2017](https://togithub.com/integrations/terraform-provider-github/issues/2017):
Add support for the require_last_push_approval flag in
github_branch_protection_v3 by
[@&#8203;georgekaz](https://togithub.com/georgekaz) in
[https://github.com/integrations/terraform-provider-github/pull/2199](https://togithub.com/integrations/terraform-provider-github/pull/2199)

##### Bugfixes

- fix(data_source_github_rest_api): just read body and convert bytes
into string by [@&#8203;riezebosch](https://togithub.com/riezebosch) in
[https://github.com/integrations/terraform-provider-github/pull/2152](https://togithub.com/integrations/terraform-provider-github/pull/2152)

##### 🛠️ Maintenance

- build(deps): bump golang.org/x/oauth2 from 0.17.0 to 0.18.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/integrations/terraform-provider-github/pull/2189](https://togithub.com/integrations/terraform-provider-github/pull/2189)
- build(deps): bump google.golang.org/protobuf from 1.32.0 to 1.33.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/integrations/terraform-provider-github/pull/2194](https://togithub.com/integrations/terraform-provider-github/pull/2194)

**Full Changelog**:
integrations/terraform-provider-github@v6.1.0...v6.2.0

###
[`v6.1.0`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v6.1.0)

[Compare
Source](https://togithub.com/integrations/terraform-provider-github/compare/v6.0.1...v6.1.0)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

- fix: validation rule for `results_per_page` of `github_repositories`
data source by [@&#8203;dschniepp](https://togithub.com/dschniepp) in
[https://github.com/integrations/terraform-provider-github/pull/2185](https://togithub.com/integrations/terraform-provider-github/pull/2185)
- fix: Prevent loading of allowed actions if not configured by
[@&#8203;Danielku15](https://togithub.com/Danielku15) in
[https://github.com/integrations/terraform-provider-github/pull/2186](https://togithub.com/integrations/terraform-provider-github/pull/2186)
- fix(data_source_github_rest_api): only allow for 404 on err by
[@&#8203;riezebosch](https://togithub.com/riezebosch) in
[https://github.com/integrations/terraform-provider-github/pull/2154](https://togithub.com/integrations/terraform-provider-github/pull/2154)
- fix: error if autolink reference not found by
[@&#8203;bradam12](https://togithub.com/bradam12) in
[https://github.com/integrations/terraform-provider-github/pull/2164](https://togithub.com/integrations/terraform-provider-github/pull/2164)
- feat: Add `github_actions_enterprise_permissions` by
[@&#8203;ErikElkins](https://togithub.com/ErikElkins) in
[https://github.com/integrations/terraform-provider-github/pull/2155](https://togithub.com/integrations/terraform-provider-github/pull/2155)
- docs: configure release notes categories based on labels by
[@&#8203;laughedelic](https://togithub.com/laughedelic) in
[https://github.com/integrations/terraform-provider-github/pull/2184](https://togithub.com/integrations/terraform-provider-github/pull/2184)

#### New Contributors

- [@&#8203;dschniepp](https://togithub.com/dschniepp) made their first
contribution in
[https://github.com/integrations/terraform-provider-github/pull/2185](https://togithub.com/integrations/terraform-provider-github/pull/2185)
- [@&#8203;riezebosch](https://togithub.com/riezebosch) made their first
contribution in
[https://github.com/integrations/terraform-provider-github/pull/2154](https://togithub.com/integrations/terraform-provider-github/pull/2154)
- [@&#8203;bradam12](https://togithub.com/bradam12) made their first
contribution in
[https://github.com/integrations/terraform-provider-github/pull/2164](https://togithub.com/integrations/terraform-provider-github/pull/2164)
- [@&#8203;ErikElkins](https://togithub.com/ErikElkins) made their first
contribution in
[https://github.com/integrations/terraform-provider-github/pull/2155](https://togithub.com/integrations/terraform-provider-github/pull/2155)
- [@&#8203;laughedelic](https://togithub.com/laughedelic) made their
first contribution in
[https://github.com/integrations/terraform-provider-github/pull/2184](https://togithub.com/integrations/terraform-provider-github/pull/2184)

**Full Changelog**:
integrations/terraform-provider-github@v6.0.1...v6.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjI1Ny4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: kireque-bot[bot] <143391978+kireque-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: panic when attempting to import github_repository_autolink_reference with invalid key

4 participants