Flagsmith / Flagsmith/terraform-provider-flagsmith

panic: runtime error: invalid memory address or nil pointer dereference

Open
#186 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6
Forks
3
Avg merge
18h 13m
Merged PRs (30d)
8

Description

Hello,
I'm encountering the following issue when trying to apply a change to a feature value.
The feature is already enable with no value, and I'm setting a value in that apply.
Even though this fails and it says cancelled, I can see that the change is effective.
If I do a plan right after, it says no change.
Thanks !

```
running 'sh -c' 'terraform1.11.3 apply -input=false "default.tfplan"'
exit status 1
flagsmith_feature_state.tenant_specific_segment_override["mytenant_myfeature"]: Modifying...

│ Error: Request cancelled

│ The plugin6.(*GRPCProvider).ApplyResourceChange request was cancelled.

Stack trace from the terraform-provider-flagsmith_v0.9.1 plugin:

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

goroutine 13 [running]:
github.com/Flagsmith/flagsmith-go-api-client.(*Client).UpdateFeatureState(0xc000295bf0, 0xc000484cc0, 0x1)
github.com/Flagsmith/flagsmith-go-api-client@v0.10.0/client.go:102 +0x401
github.com/Flagsmith/terraform-provider-flagsmith/flagsmith.(*featureStateResource).Update(0xc0004c62f0, {0xe4cfc8, 0xc0003cb560}, {{{{0xe51d90, 0xc0003d0ab0}, {0xbf1940, 0xc0003d0630}}, {0xe54240, 0xc0002aec30}}, {{{0xe51d90, ...}, ...}, ...}, ...}, ...)
github.com/Flagsmith/terraform-provider-flagsmith/flagsmith/resource_feature_state.go:278 +0x539
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).UpdateResource(0xc000187688, {0xe4cfc8, 0xc0003cb560}, 0xc0003b9480, 0xc0003b9458)
github.com/hashicorp/terraform-plugin-framework@v1.13.0/internal/fwserver/server_updateresource.go:122 +0x6ee
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ApplyResourceChange(0xc000187688, {0xe4cfc8, 0xc0003cb560}, 0xc000209ea0, 0xc0003b9640)
github.com/hashicorp/terraform-plugin-framework@v1.13.0/internal/fwserver/server_applyresourcechange.go:102 +0x192
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ApplyResourceChange(0xc000187688, {0xe4cfc8?, 0xc0003cb470?}, 0xc000209e00)
github.com/hashicorp/terraform-plugin-framework@v1.13.0/internal/proto6server/server_applyresourcechange.go:55 +0x38e
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc00021eb40, {0xe4cfc8?, 0xc0003caae0?}, 0xc0004a2540)
github.com/hashicorp/terraform-plugin-go@v0.25.0/tfprotov6/tf6server/server.go:865 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0xcde480, 0xc00021eb40}, {0xe4cfc8, 0xc0003caae0}, 0xc0002c7400, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.25.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:611 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00014f400, {0xe4cfc8, 0xc0003caa50}, {0xe52ee0, 0xc0000d6000}, 0xc0003c0b40, 0xc00038c270, 0x13baab8, 0x0)
google.golang.org/grpc@v1.67.1/server.go:1394 +0xe2b
google.golang.org/grpc.(*Server).handleStream(0xc00014f400, {0xe52ee0, 0xc0000d6000}, 0xc0003c0b40)
google.golang.org/grpc@v1.67.1/server.go:1805 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
google.golang.org/grpc@v1.67.1/server.go:1029 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 7
google.golang.org/grpc@v1.67.1/server.go:1040 +0x125

Error: The terraform-provider-flagsmith_v0.9.1 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.
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in flagsmith/resource_feature_state.go at featureStateResource.Update line 278, then inspect the UpdateFeatureState call reported at client.go:102. Reproduce an apply that adds a value to an already-enabled feature state and verify that it completes without a nil-pointer panic or cancellation while the change is applied successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, terraform
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.