Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider crash when credentials are invalid #1306

Closed
rrey-aviatrix opened this issue Sep 28, 2022 · 2 comments
Closed

Provider crash when credentials are invalid #1306

rrey-aviatrix opened this issue Sep 28, 2022 · 2 comments
Labels
Status: Stale Used by stalebot to clean house

Comments

@rrey-aviatrix
Copy link

Terraform Version

Terraform v1.2.5
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.32.0
+ provider registry.terraform.io/integrations/github v5.3.0

Your version of Terraform is out of date! The latest version
is 1.3.0. You can update by downloading from https://www.terraform.io/downloads.html

Issue not related to terraform version (see later)

Affected Resource(s)

Provider authentication

Terraform Configuration Files

N/A

Debug Output

Copying the interesting part:

[...]
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: 2022/09/28 15:07:03 [DEBUG] Github API Response Details:
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: ---[ RESPONSE ]--------------------------------------
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: HTTP/2.0 401 Unauthorized
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Content-Length: 80
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Access-Control-Allow-Origin: *
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Content-Security-Policy: default-src 'none'
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Content-Type: application/json; charset=utf-8
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Date: Wed, 28 Sep 2022 13:07:03 GMT
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Server: GitHub.com
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: Vary: Accept-Encoding, Accept, X-Requested-With
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Content-Type-Options: nosniff
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Frame-Options: deny
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Github-Media-Type: github.v3; param=surtur-preview; format=json
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Github-Request-Id: D831:B92F:273C99E:27CC6DB:633446F6
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Ratelimit-Limit: 60
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Ratelimit-Remaining: 39
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Ratelimit-Reset: 1664373018
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Ratelimit-Resource: core
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Ratelimit-Used: 21
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: X-Xss-Protection: 0
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0:-
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: {
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0:  "message": "Bad credentials",
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0:  "documentation_url": "https://docs.github.com/rest"
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: }
2022-09-28T15:07:03.291+0200 [DEBUG] provider.terraform-provider-github_v4.23.0: -----------------------------------------------------
[...]

Expected Behavior

No error

Actual Behavior

Stack trace from the terraform-provider-github_v4.23.0 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x78 pc=0x19acded]

goroutine 99 [running]:
github.com/terraform-providers/terraform-provider-github/github.resourceGithubRepositoryEnvironmentRead(0xc000138690, 0x1a44660, 0xc00028eb00, 0xc000138690, 0x0)
    github.com/terraform-providers/terraform-provider-github/github/resource_github_repository_environment.go:125 +0x36d
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0000ab980, 0xc0006730e0, 0x1a44660, 0xc00028eb00, 0xc000110770, 0x0, 0x0)
    github.com/hashicorp/terraform-plugin-sdk@v1.7.0/helper/schema/resource.go:455 +0x12e
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc000288010, 0x1d9b3d0, 0xc000247b60, 0xc000672ff0, 0xc000288010, 0xc000247b60, 0xc000161a50)
    github.com/hashicorp/terraform-plugin-sdk@v1.7.0/internal/helper/plugin/grpc_provider.go:525 +0x3dd
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x1bc54e0, 0xc000288010, 0x1d9b3d0, 0xc000247b60, 0xc00026e840, 0x0, 0x1d9b3d0, 0xc000247b60, 0xc0008fc000, 0xa1)
    github.com/hashicorp/terraform-plugin-sdk@v1.7.0/internal/tfplugin5/tfplugin5.pb.go:3153 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004f2160, 0x1da2eb8, 0xc000102600, 0xc00067e400, 0xc000282d50, 0x23285f0, 0x0, 0x0, 0x0)
    google.golang.org/grpc@v1.23.0/server.go:995 +0x482
google.golang.org/grpc.(*Server).handleStream(0xc0004f2160, 0x1da2eb8, 0xc000102600, 0xc00067e400, 0x0)
    google.golang.org/grpc@v1.23.0/server.go:1275 +0xd2c
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0001a0450, 0xc0004f2160, 0x1da2eb8, 0xc000102600, 0xc00067e400)
    google.golang.org/grpc@v1.23.0/server.go:710 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.23.0/server.go:708 +0xa5

Error: The terraform-provider-github_v4.23.0 plugin crashed!

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Use a GITHUB_TOKEN that expired (it was my case)
  2. try to terraform plan any code that use a github resource.

Important Factoids

The provider version in our codebase is pinned to 4.23 and has been working well for months.
The CI started to fail with the provider panic without any significant change in the code.

After raising Terraform logs to debug, I could identify the source of the problem to origin from the Bad credentials response from the API.
I double checked the validity of my token and could see that it expired. After I re-generated a token, I got rid of the error.

I reproduced the issue with the latest provider version (v5.3.0 when writting these lines).
The problem seems to come from an unhandle response type when credentials are invalid.

References

@rrey-aviatrix
Copy link
Author

Linked #1262 because the comments (especialy this one) seems to point at the same source problem

@github-actions
Copy link

👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Jun 26, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Used by stalebot to clean house
Projects
None yet
Development

No branches or pull requests

1 participant