codecutout / terraform-provider-powerbi

Terraform Power BI Provider
MIT License
14 stars 16 forks source link

Runtime Error: invalid memory address or nil pointer dereference on authentication #56

Open PlayAnyData opened 2 years ago

PlayAnyData commented 2 years ago

I am trying to create a workspace using:

provider "powerbi" { tenant_id = "deleted" client_id = "deleted" client_secret = "deleted" }

resource "powerbi_workspace" "myworkspace" { name = "Automatically" }

Executing terraform apply the application crashes with the following exception:

powerbi_workspace.myworkspace: Creating... ╷ │ Error: Plugin did not respond │ │ with powerbi_workspace.myworkspace, │ on main.tf line 16, in resource "powerbi_workspace" "myworkspace": │ 16: resource "powerbi_workspace" "myworkspace" { │ │ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The │ plugin logs may contain more details. ╵

Stack trace from the terraform-provider-powerbi_v1.4.0 plugin:

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

goroutine 36 [running]: github.com/codecutout/terraform-provider-powerbi/internal/powerbiapi.(retryIntermittentErrorRoundTripper).RoundTrip(0xc0001e97b0, 0xc000140200, 0x10, 0xc0005480b0, 0x1) github.com/codecutout/terraform-provider-powerbi/internal/powerbiapi/client_retry_intermittent_error.go:23 +0x9egithub.com/codecutout/terraform-provider-powerbi/internal/powerbiapi.(errorOnUnsuccessfulRoundTripper).RoundTrip(0xc0001e97c0, 0xc000140200, 0x1071b5b, 0xd, 0xc00013e200) github.com/codecutout/terraform-provider-powerbi/internal/powerbiapi/client_error.go:50 +0x55 github.com/codecutout/terraform-provider-powerbi/internal/powerbiapi.(bearerTokenRoundTripper).RoundTrip(0xc0005905a0, 0xc000140100, 0xc0005905a0, 0x0, 0x0) github.com/codecutout/terraform-provider-powerbi/internal/powerbiapi/client_auth.go:62 +0x1b4 net/http.send(0xc000140100, 0x12b86c0, 0xc0005905a0, 0x0, 0x0, 0x0, 0xc00000eb90, 0xb, 0x1, 0x0) net/http/client.go:252 +0x43e net/http.(Client).send(0xc0005905d0, 0xc000140100, 0x0, 0x0, 0x0, 0xc00000eb90, 0x0, 0x1, 0xfae140) net/http/client.go:176 +0xfa net/http.(Client).do(0xc0005905d0, 0xc000140100, 0x0, 0x0, 0x0) net/http/client.go:699 +0x44a net/http.(Client).Do(...) net/http/client.go:567 github.com/codecutout/terraform-provider-powerbi/internal/powerbiapi.(Client).doJSON(0xc0007ae378, 0x1069911, 0x4, 0x109d8c5, 0x3a, 0xf42600, 0xc0005486a0, 0xe6a940, 0xc000552400, 0xd42dea, ...) github.com/codecutout/terraform-provider-powerbi/internal/powerbiapi/client.go:77 +0x95 github.com/codecutout/terraform-provider-powerbi/internal/powerbiapi.(Client).CreateGroup(...) github.com/codecutout/terraform-provider-powerbi/internal/powerbiapi/groups.go:79 github.com/codecutout/terraform-provider-powerbi/internal/powerbi.createWorkspace(0xc0004b8770, 0x105d320, 0xc0007ae378, 0x2, 0x1a6f400) github.com/codecutout/terraform-provider-powerbi/internal/powerbi/resource_workspace.go:42 +0x171 github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Resource).Apply(0xc0004ad440, 0xc00059e5a0, 0xc00000dd60, 0x105d320, 0xc0007ae378, 0xf0cf01, 0xc0001338b8, 0xc000544a50) github.com/hashicorp/terraform-plugin-sdk@v1.16.0/helper/schema/resource.go:310 +0x365 github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Provider).Apply(0xc0001f0300, 0xc000133a38, 0xc00059e5a0, 0xc00000dd60, 0xc000156868, 0xc00000e7e8, 0xf0ed00) github.com/hashicorp/terraform-plugin-sdk@v1.16.0/helper/schema/provider.go:294 +0x99 github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(GRPCProviderServer).ApplyResourceChange(0xc0000a25b0, 0x12d2c40, 0xc0005441b0, 0xc0004b8000, 0xc0000a25b0, 0xc0005441b0, 0xc0004cdba0) github.com/hashicorp/terraform-plugin-sdk@v1.16.0/internal/helper/plugin/grpc_provider.go:885 +0x8b4 github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x102b320, 0xc0000a25b0, 0x12d2c40, 0xc0005441b0, 0xc00011a540, 0x0, 0x12d2c40, 0xc0005441b0, 0xc000148090, 0x84) github.com/hashicorp/terraform-plugin-sdk@v1.16.0/internal/tfplugin5/tfplugin5.pb.go:3305 +0x217 google.golang.org/grpc.(Server).processUnaryRPC(0xc0006568c0, 0x12de860, 0xc000643b00, 0xc000140000, 0xc000116540, 0x1a346e0, 0x0, 0x0, 0x0) google.golang.org/grpc@v1.30.0/server.go:1171 +0x50a google.golang.org/grpc.(Server).handleStream(0xc0006568c0, 0x12de860, 0xc000643b00, 0xc000140000, 0x0) google.golang.org/grpc@v1.30.0/server.go:1494 +0xccd google.golang.org/grpc.(Server).serveStreams.func1.2(0xc0000324f0, 0xc0006568c0, 0x12de860, 0xc000643b00, 0xc000140000) google.golang.org/grpc@v1.30.0/server.go:834 +0xa1 created by google.golang.org/grpc.(*Server).serveStreams.func1 google.golang.org/grpc@v1.30.0/server.go:832 +0x204

Error: The terraform-provider-powerbi_v1.4.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely helpful if you could report the crash with the plugin's maintainers so that it can be fixed. The output above should help diagnose the issue.

Update: This happened to me within WSL2 (Ubuntu) on windows. However, on windows the same configuration works fine. I would prefer using Ubuntu.

alex-davies commented 2 years ago

That is an interesting one

the stack trace points to the http and netwrok error handling code. It may not be handling lower level network connection issues; The exact line seems to be where we pull http status objects out of responses this might happen if network errors prevent us for getting response objects.

Is your network access in WSL2 setup correctly? Are you able to successfully wget https://login.microsoftonline.com?

PlayAnyData commented 2 years ago

Yes, this is working fine:

wget https://login.microsoftonline.com --2021-11-22 06:04:05-- https://login.microsoftonline.com/ Resolving login.microsoftonline.com (login.microsoftonline.com)... 20.190.159.134, 40.126.31.135, 40.126.31.137, ... Connecting to login.microsoftonline.com (login.microsoftonline.com)|20.190.159.134|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://www.office.com/login# [following] --2021-11-22 06:04:05-- https://www.office.com/login Resolving www.office.com (www.office.com)... 13.107.6.156, 2620:1ec:a92::156 Connecting to www.office.com (www.office.com)|13.107.6.156|:443... connected. HTTP request sent, awaiting response... 302 Found (...) HTTP request sent, awaiting response... 200 OK Length: 193728 (189K) [text/html] Saving to: ‘index.html’

00kkcp9230 commented 2 years ago

I was having a very similar issue. In my case the problem was DNS resolution from within WSL2. Changing nameserver to a public DNS server like 8.8.8.8 did the trick for me. Here's a reference how to edit DNS settings on WSL2: https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6

jeff-99 commented 1 year ago

I had the same issue and changing the DNS server in WSL2 fixed it for me. Weird issue if you ask me