bnjns / terraform-provider-metabase

Mozilla Public License 2.0
3 stars 0 forks source link

0.8.0+ crashes - non default schedule configuration #127

Closed davesade closed 2 days ago

davesade commented 1 week ago

Terraform CLI and Terraform AWS Provider Version

Terraform 1.8.5

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

# Copy-paste your Terraform configurations here - for large Terraform configs,
# you can also create a reproducer repo and share the link here.

Debug Output

Stack trace from the terraform-provider-metabase_v0.8.0 plugin:

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

goroutine 30 [running]:
terraform-provider-metabase/internal/provider.buildScheduleSettings(0x0)
        terraform-provider-metabase/internal/provider/database_resource.go:289 +0x115
terraform-provider-metabase/internal/provider.buildSchedules(0xc00043e750)
        terraform-provider-metabase/internal/provider/database_resource.go:305 +0x165
terraform-provider-metabase/internal/provider.mapDatabaseToState({0xd3f288, 0xc00035b6e0}, 0xc00043e750, 0xc0000003c0)
        terraform-provider-metabase/internal/provider/database_resource.go:281 +0x19c
terraform-provider-metabase/internal/provider.(*DatabaseResource).Read(0xc0003f0120, {0xd3f288, 0xc00035b6e0}, {{{{0xd43eb8, 0xc0004e7590}, {0xb262e0, 0xc0004e6c30}}, {0xd45b70, 0xc0004bad70}}, 0xc0003f0130, ...}, ...)
        terraform-provider-metabase/internal/provider/database_resource.go:108 +0x1bb
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ReadResource(0xc0000f76c0, {0xd3f288, 0xc00035b6e0}, 0xc00035b740, 0xc00063b6c8)
        github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/fwserver/server_readresource.go:101 +0x62e
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ReadResource(0xc0000f76c0, {0xd3f288?, 0xc00035b5f0?}, 0xc00038ad00)
        github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/proto6server/server_readresource.go:55 +0x38e
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc0001f08c0, {0xd3f288?, 0xc00035ae70?}, 0xc0000ecf50)
        github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:784 +0x309
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0xbf7000, 0xc0001f08c0}, {0xd3f288, 0xc00035ae70}, 0xc000497480, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:482 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001a5000, {0xd3f288, 0xc00035ad50}, {0xd44820, 0xc000488000}, 0xc0000c38c0, 0xc00027db90, 0x122c528, 0x0)
        google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc0001a5000, {0xd44820, 0xc000488000}, 0xc0000c38c0)
        google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 35
        google.golang.org/grpc@v1.63.2/server.go:1030 +0x125

Error: The terraform-provider-metabase_v0.8.0 plugin crashed!

Panic Output

Expected Behavior

All should work, as it was working with v 0.7.1 before.

Actual Behavior

It crashes during plan phase.

Steps to Reproduce

  1. terraform plan

References

Not sure, but we think it's due to a change of schedules behavior in Metabase - https://github.com/bnjns/terraform-provider-metabase/compare/v0.7.1...v0.8.0#diff-48fd8dd51e44a1407938cfa2c28f5920f478fa5bfb58e149b459b3870ef7e62bR287 - in our case we do use non-default settings for schedules and it seems it's broken.

image

bnjns commented 1 week ago

Ah yes, there was a refactor in v8.0.0 that changed the schedules attribute to use the predetermined object structure rather than a general map, and it looks like it assumes each schedule always exists (even though the SDK allows nil).

To make it easier to reproduce and test on my side, what version of Metabase are you using?

sbrudz commented 2 days ago

We're on v1.49.18. Thank you for looking into this!

bnjns commented 2 days ago

This should be fixed in v0.9.1, but let me know if you still experience it

sbrudz commented 6 hours ago

Great - thank you!