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

data source snowflake_dynamic_tables: panic : runtime error: index out of range [1] with length 1 #2217

Closed
hieu-cc opened this issue Nov 27, 2023 · 1 comment · Fixed by #2234
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@hieu-cc
Copy link

hieu-cc commented Nov 27, 2023

Terraform CLI and Provider Versions

Terraform v1.6.4
on darwin_arm64
+ provider registry.terraform.io/snowflake-labs/snowflake v0.76.0

Terraform Configuration

data "snowflake_dynamic_tables" "current" {
  in {
    database = "MYDB"
    schema   = "MYSCHEMA"
  }
}

Expected Behavior

No errors, even if the database and schema don't exist.

Actual Behavior

After running terraform plan / terraform apply.

I receive the following error:

data.snowflake_dynamic_tables.current: Reading...

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ReadDataSource request was cancelled.
╵

Stack trace from the terraform-provider-snowflake_v0.76.0 plugin:

panic: runtime error: index out of range [1] with length 1

goroutine 81 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.NewDatabaseObjectIdentifierFromFullyQualifiedName({0x140007d31c8?, 0x14000d8b1a0?})
	github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/identifier_helpers.go:159 +0xb8
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/datasources.ReadDynamicTables(0x0?, {0x106395740?, 0x1400057ec30?})
	github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/datasources/dynamic_tables.go:229 +0x3a0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x1063d7080?, {0x1063d7080?, 0x140005a5aa0?}, 0xd?, {0x106395740?, 0x1400057ec30?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:783 +0x134
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0x14000b602a0, {0x1063d7080, 0x140005a5aa0}, 0x140005dc480, {0x106395740, 0x1400057ec30})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1015 +0x130
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0x1400080f6e0, {0x1063d7080?, 0x140005a5920?}, 0x14000a80c80)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1237 +0x304
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadDataSource({{0x1063f3ba0?, 0x1400080f6e0?}}, {0x1063d7080?, 0x140005a5920?}, 0x14000a80c60?)
	github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:108 +0x238
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadDataSource(0x1063d6fd8?, {0x1063d7080?, 0x140005a55f0?}, 0x14000a80c60)
	github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ReadDataSource.go:36 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadDataSource(0x14000a9c960, {0x1063d7080?, 0x140005a4c60?}, 0x140005ba1e0)
	github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:697 +0x368
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadDataSource_Handler({0x1063426e0?, 0x14000a9c960}, {0x1063d7080, 0x140005a4c60}, 0x14000b561c0, 0x0)
	github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:503 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400002d2c0, {0x1063e6900, 0x14000207860}, 0x140005ccb40, 0x140007fc7b0, 0x107003208, 0x0)
	google.golang.org/[email protected]/server.go:1376 +0xbe0
google.golang.org/grpc.(*Server).handleStream(0x1400002d2c0, {0x1063e6900, 0x14000207860}, 0x140005ccb40, 0x0)
	google.golang.org/[email protected]/server.go:1753 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	google.golang.org/[email protected]/server.go:998 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:996 +0x16c

Error: The terraform-provider-snowflake_v0.76.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.

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

High

Logs

https://gist.github.com/hieu-cc/92d3bcb923f149bfd1dcd12d70154ca0

Additional Information

No response

@hieu-cc hieu-cc added the bug Used to mark issues with provider's incorrect behavior label Nov 27, 2023
@sfc-gh-asawicki
Copy link
Collaborator

Hey @hieu-cc. Thanks for reporting the issue.

There are two things here:

  1. We have an incorrect datasource definition: you should not be able to set both database and schema inside in. We will fix the conflictsWith definition.
  2. To show using in set only schema but qualify the name. We will update the docs to be precise on utilizing the data resource.

Please let me know if setting only qualified schema solves your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants