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

terraform import snowflake_procedure - plugin runtime error: index out of range #993

Closed
MatthewChudleigh-LMG opened this issue May 4, 2022 · 4 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@MatthewChudleigh-LMG
Copy link

Provider Version

0.33.1

Terraform Version

1.1.7 on linux_amd64

Describe the bug

On attempting to import a stored procedure, the plugin crashes:

Error Message:

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

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

goroutine 37 [running]:
github.com/chanzuckerberg/terraform-provider-snowflake/pkg/resources.ReadProcedure(0xc0000c0980, {0x119faa0, 0xc000664b60})
        github.com/chanzuckerberg/terraform-provider-snowflake/pkg/resources/procedure.go:258 +0x12bd
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x11b4cb5, {0x13c8f98, 0xc000468e40}, 0x24, {0x119faa0, 0xc000664b60})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:346 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0002aa380, {0x13c8f98, 0xc000468e40}, 0xc000665860, {0x119faa0, 0xc000664b60})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:635 +0x35b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0002e00c0, {0x13c8f98, 0xc000468e40}, 0xc000468ec0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/grpc_provider.go:576 +0x534
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0005abf40, {0x13c9040, 0xc0005af3e0}, 0xc00046cba0)
        github.com/hashicorp/terraform-plugin-go@v0.7.1/tfprotov5/tf5server/server.go:746 +0x537
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x116f0e0, 0xc0005abf40}, {0x13c9040, 0xc0005af3e0}, 0xc00046cb40, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.7.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004c2700, {0x13dc0c8, 0xc000139040}, 0xc0005f45a0, 0xc000370b10, 0x1b81e90, 0x0)
        google.golang.org/grpc@v1.44.0/server.go:1282 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc0004c2700, {0x13dc0c8, 0xc000139040}, 0xc0005f45a0, 0x0)
        google.golang.org/grpc@v1.44.0/server.go:1616 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.44.0/server.go:921 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.44.0/server.go:919 +0x294

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

Expected behavior

  • The stored procedure should be imported into the local state

Code samples and commands

main.tf:

terraform {
  required_providers {
    snowflake = {
      source  = "chanzuckerberg/snowflake"
      version = "0.33.1"
    }
  }
}

provider "snowflake" {
  account          = "..."
  region           = "ap-southeast-2"
  username         = "tf_snow"
  role             = "ACCOUNTADMIN"
  private_key_path = ...
}

resource "snowflake_procedure" "proc" {
}

terraform import snowflake_procedure.proc 'DATABASE|SCHEMA|STORED_PROC_NAME|boolean'

Additional context

  • Other imports for the database, schema and stage, work without any issue.
@MatthewChudleigh-LMG MatthewChudleigh-LMG added the bug Used to mark issues with provider's incorrect behavior label May 4, 2022
@Sophiakorginska
Copy link

Hi team! I am facing the same issue with importing snowflake_procedure
Provider version:
0.87.3-pre
Terraform version:
1.3.5
Error:

Stack trace from the terraform-provider-snowflake_v0.87.3-pre plugin:

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

goroutine 146 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.NewSchemaObjectIdentifierFromFullyQualifiedName({0x140011a40a0?, 0x104b3bc88?})
        github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/identifier_helpers.go:215 +0x344
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.ReadContextProcedure({0x10675f4b0, 0x14000dc0930}, 0x140010a0700, {0x1063786a0?, 0x14000d0c718?})
        github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/procedure.go:527 +0xfc
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x14000c8ea80, {0x10675f408, 0x140009ae1b0}, 0xd?, {0x1063786a0, 0x14000d0c718})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:795 +0xe8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0x14000c8ea80, {0x10675f408, 0x140009ae1b0}, 0x14000d70b60, {0x1063786a0, 0x14000d0c718})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:1089 +0x430
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0x14000db44f8, {0x10675f408?, 0x140009ae060?}, 0x14001042780)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:663 +0x3e4
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x106774a78?, 0x14000db44f8?}}, {0x10675f408?, 0x140009ae060?}, 0x14001042600?)
        github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:176 +0x228
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0x10675f440?, {0x10675f408?, 0x14000c0eed0?}, 0x14001042600)
        github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ReadResource.go:35 +0x184
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0x14000d9a3c0, {0x10675f408?, 0x14000153a40?}, 0x14000f402a0)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:787 +0x390
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x1066c8680?, 0x14000d9a3c0}, {0x10675f408, 0x14000153a40}, 0x140010a0180, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x164
google.golang.org/grpc.(*Server).processUnaryRPC(0x140000f0f00, {0x10675f408, 0x14000153440}, {0x106770060, 0x14000557d40}, 0x14000000fc0, 0x140008431a0, 0x10761bc08, 0x0)
        google.golang.org/grpc@v1.60.0/server.go:1372 +0xb8c
google.golang.org/grpc.(*Server).handleStream(0x140000f0f00, {0x106770060, 0x14000557d40}, 0x14000000fc0)
        google.golang.org/grpc@v1.60.0/server.go:1783 +0xc4c
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.60.0/server.go:1016 +0x5c
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 55
        google.golang.org/grpc@v1.60.0/server.go:1027 +0x138

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

Command:
terraform import 'snowflake_procedure.clean_procedure' 'MYDB|MYSTAGE|ETL_CLEAN_TABLE_BY_TIME|varchar-number'

@sfc-gh-asawicki
Copy link
Collaborator

Hey @Sophiakorginska. Thanks for reaching out to us.

In version 0.85.0 the identifier format for procedures was changes but as I see, the example for import was not. Caqn you check if you are able to import this procedure using terraform import 'snowflake_procedure.clean_procedure' 'MYDB.MYSTAGE.ETL_CLEAN_TABLE_BY_TIME(varchar-number)' instead?

@Sophiakorginska
Copy link

Hi @sfc-gh-asawicki,
Thanks for the quick response. Looks like there should be terraform import 'snowflake_procedure.clean_procedure' 'MYDB.MYSTAGE.ETL_CLEAN_TABLE_BY_TIME(varchar, number)'. With comma, it was able to import the procedure!

sfc-gh-asawicki added a commit that referenced this issue Apr 11, 2024
sfc-gh-asawicki added a commit that referenced this issue Apr 12, 2024
Fixed a few issues (from GH and reported internally):
- Do not swallow error in access token setup (References: #2678)
- Fix import example after v0.85.0 changes (References: #993)
- Fix alter allowed values for tags (reported internally)
- Suppress diff for quoted on_table/on_view in stream resource
(References: #2672)
- Test primary key creation (References: #2674 #2629)
- Fix v0.85.0 state migrator for external functions (References: #2694)
@sfc-gh-asawicki
Copy link
Collaborator

We are closing this issue as part of a cleanup described in announcement. If you believe that the issue is still valid in v0.89.0, please open a new ticket.

@sfc-gh-asawicki sfc-gh-asawicki closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
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

3 participants