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.terraform-provider-split_v0.10.1: panic: runtime error: invalid memory address or nil pointer dereference #140

Open
6ripley opened this issue Mar 23, 2023 · 3 comments
Assignees

Comments

@6ripley
Copy link

6ripley commented Mar 23, 2023

Hi there,

Terraform Version

Terraform v1.4.2
on darwin_arm64
+ provider registry.terraform.io/davidji99/split v0.10.1

Debug Output

https://gist.github.com/6ripley/4fab5da4044e370e9a118748b798c3ac

Panic Output

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x1044fa33c]

goroutine 182 [running]:
github.com/davidji99/terraform-provider-split/split.resourceSplitSegmentEnvironmentAssociationRead({0x104996980?, 0x14000570630?}, 0x14000194280, {0x1048be7a0?, 0x14000266e80?})
        /home/runner/work/terraform-provider-split/terraform-provider-split/split/resource_split_segment_environment_association.go:136 +0x42c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x1400019eee0, {0x104996980, 0x14000570630}, 0xd?, {0x1048be7a0, 0x14000266e80})
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:724 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0x1400019eee0, {0x104996980, 0x14000570630}, 0x140006032b0, {0x1048be7a0, 0x14000266e80})
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:1015 +0x46c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0x14000250480, {0x104996980?, 0x14000570510?}, 0x14000598e40)
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/grpc_provider.go:613 +0x40c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0x1400026cdc0, {0x104996980?, 0x1400056fef0?}, 0x14000380fc0)
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.14.1/tfprotov5/tf5server/server.go:748 +0x3ec
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x104960540?, 0x1400026cdc0}, {0x104996980, 0x1400056fef0}, 0x140001c6a80, 0x0)
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.14.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400026a1e0, {0x1049994a0, 0x140004029c0}, 0x1400039f9e0, 0x140003c4f30, 0x104e32550, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.50.1/server.go:1340 +0xb90
google.golang.org/grpc.(*Server).handleStream(0x1400026a1e0, {0x1049994a0, 0x140004029c0}, 0x1400039f9e0, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.50.1/server.go:1713 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.50.1/server.go:965 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.50.1/server.go:963 +0x298

Error: The terraform-provider-split_v0.10.1 plugin crashed!

Expected Behavior

Terraform should successfully refresh configuration or throw a useful error.

Actual Behavior

Plugin crashes when refreshing state. After re-creating tfstate file and importing existing resources terraform works for the first time when one of the below commands are issued. When apply with refresh=false is issued, it works for printing planned changes but crashes when applied.
Tried applying less resources per command but once it reaches certain number of resources it fails on refresh every time.

Steps to Reproduce

terraform apply
terraform apply -refresh-only

Important Factoids

Tested with Mac with M1 and with Ubuntu 22.04
Already tried setting up export GODEBUG=asyncpreemptoff=1 on mac, recreating tfstate file from import multiple times, re-initializing terraform.

Any help will be appreciated, thanks!

@davidji99
Copy link
Owner

Hey @6ripley,

Looks like the first issue is the getErr.Error() was a mistake (copy-n-paste), so I will remove that.

However, I'd like to know the totalCount that is returned when you use curl or Postman to GET this endpoint: https://docs.split.io/reference/list-segments-in-environment. I suspect there's a pagnation issue and the default pagination offset and limits are not enough.

@6ripley
Copy link
Author

6ripley commented Apr 11, 2023

Hi @davidji99,

Thanks for getting back to me!
totalcount varies between the environments but here are the listings and it seems some of them are way above the limit:

"offset":0,"limit":20,"totalCount":68
"offset":0,"limit":20,"totalCount":3
"offset":0,"limit":20,"totalCount":79
"offset":0,"limit":20,"totalCount":26
"offset":0,"limit":20,"totalCount":7
"offset":0,"limit":20,"totalCount":11
"offset":0,"limit":20,"totalCount":9

@davidji99
Copy link
Owner

THanks @6ripley. As I suspected, the API client needs to support pagination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants