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

[Bug]: Incorrect import syntax causes plugin crash #3324

Open
1 task
jamiekt opened this issue Jan 6, 2025 · 1 comment
Open
1 task

[Bug]: Incorrect import syntax causes plugin crash #3324

jamiekt opened this issue Jan 6, 2025 · 1 comment
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@jamiekt
Copy link
Contributor

jamiekt commented Jan 6, 2025

Terraform CLI Version

1.10.3

Terraform Provider Version

0.92.0

Company Name

No response

Terraform Configuration

import {
  for_each = local.all_schemas
  to       = snowflake_schema.schemas[each.key]
  id       = "${module.resources.resource_group_database.staging}.${each.key}"
}

Category

category:resource

Object type(s)

resource:schema

Expected Behavior

I used the wrong syntax to define the ID of the schema in my import statement.
I would expect the provider to exit elegantly and report a useful error message.

Actual Behavior

The provider crashed

  │ Error: Plugin did not respond
  │ 
  │ The plugin encountered an error, and failed to respond to the
  │ plugin6.(*GRPCProvider).ReadResource call. The plugin logs may contain more
  │ details.
  ╵
  ╷
  │ Error: Request cancelled
  │ 
  │ The plugin6.(*GRPCProvider).ImportResourceState request was cancelled.
  ╵
Stack trace from the terraform-provider-snowflake_v0.92.0 plugin:
  panic: interface conversion: sdk.ObjectIdentifier is sdk.AccountObjectIdentifier, not sdk.DatabaseObjectIdentifier
  goroutine 911 [running]:
  github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.ReadSchema(0xc0000e5200, {0x1cd1dc0?, 0xc00007d0a8?})
  	github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/schema.go:108 +0x899
  github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x2482c98?, {0x2482c98?, 0xc000e0a720?}, 0xd?, {0x1cd1dc0?, 0xc00007d0a8?})
  	github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:783 +0x163
  github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000629ea0, {0x2482c98, 0xc000e0a720}, 0xc0008b68f0, {0x1cd1dc0, 0xc00007d0a8})
  	github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:1089 +0x552
  github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000a82c48, {0x2482c98?, 0xc000e0a5d0?}, 0xc000918e40)
  	github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:667 +0x48a
  github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x24999c0?, 0xc000a82c48?}}, {0x2482c98?, 0xc000e0a5d0?}, 0xc000918c80?)
  	github.com/hashicorp/terraform-plugin-mux@v0.15.0/tf5to6server/tf5to6server.go:215 +0x225
  github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0x2482cd0?, {0x2482c98?, 0xc000e0a2d0?}, 0xc000918c80)
  	github.com/hashicorp/terraform-plugin-mux@v0.15.0/tf6muxserver/mux_server_ReadResource.go:35 +0x193
  github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc000a8efa0, {0x2482c98?, 0xc0012d1a40?}, 0xc001316000)
  	github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/tf6server/server.go:776 +0x4c3
  github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x2038060?, 0xc000a8efa0}, {0x2482c98, 0xc0012d1a40}, 0xc0000e4e00, 0x0)
  	github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:482 +0x169
  google.golang.org/grpc.(*Server).processUnaryRPC(0xc000a2e[600](https://github.com/hellofresh/snowflake-automation/actions/runs/12637132973/job/35210827802#step:6:605), {0x2482c98, 0xc0012d19b0}, {0x2494b60, 0xc000148300}, 0xc0007a6ea0, 0xc000c28c90, 0x3443aa8, 0x0)
  	google.golang.org/grpc@v1.63.2/server.go:1369 +0xe23
  google.golang.org/grpc.(*Server).handleStream(0xc000a2e600, {0x2494b60, 0xc000148300}, 0xc0007a6ea0)
  	google.golang.org/grpc@v1.63.2/server.go:1780 +0x1016
  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 40
  	google.golang.org/grpc@v1.63.2/server.go:1030 +0x135
  Error: The terraform-provider-snowflake_v0.92.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

Install v0.92.0 of the terraform provider
Attempt to import the definition of a schema that uses a dot (as opposed to a vertical bar) between the database name and schema name

How much impact is this issue causing?

Low

Logs

No response

Additional Information

I haven't tested this on a more recent version than 0.92.0. Perhaps its already been fixed.

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@jamiekt jamiekt added the bug Used to mark issues with provider's incorrect behavior label Jan 6, 2025
@sfc-gh-jmichalak
Copy link
Collaborator

Hi @jamiekt 👋

We've reworked the schema resource in v0.94.0 (release notes, migration guide). In the reworked resources, we change the import syntax to use a dot, and fail with a proper message when it's invalid. Please upgrade to at least this version (note that the newest one is v1.0.1).

@sfc-gh-jmichalak sfc-gh-jmichalak self-assigned this Jan 7, 2025
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

No branches or pull requests

2 participants