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]: snowflake_table_column_masking_policy_application: panic :runtime error: index out of range [1] with length 1 #3077

Closed
1 task
paruchurij opened this issue Sep 15, 2024 · 2 comments
Assignees
Labels
general-usage General help/usage questions resource:table_column_masking_policy_application Issue connected to the snowflake_table_column_masking_policy_application resource

Comments

@paruchurij
Copy link

Terraform CLI Version

Terraform v1.5.4 on darwin_arm64

Terraform Provider Version

provider registry.terraform.io/snowflake-labs/snowflake v0.76.0

Terraform Configuration

resource "snowflake_table_column_masking_policy_application" "application0" {
  table          = "MYTABLE"
  column         = "MY_MASKING_COLUMN"
  masking_policy = "MYDB.MYSCHEMA.MYMASKINGPOLICY"
}

Category

category:resource

Object type(s)

resource:masking_policy

Expected Behavior

Plan works as expected but when running terraform apply running into below error:

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

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

goroutine 98 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake.SchemaObjectIdentifierFromQualifiedName({0x14000a98650?, 0x10136fbb4?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake/identifier.go:57 +0x178
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.CreateTableColumnMaskingPolicyApplication(0x0?, {0x101a91740?, 0x14000a845b0})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/table_column_masking_policy_application.go:52 +0x58
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x101ad3080?, {0x101ad3080?, 0x14000eb1da0?}, 0xd?, {0x101a91740?, 0x14000a845b0?})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:766 +0x134
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x14000e38540, {0x101ad3080, 0x14000eb1da0}, 0x140004fe5b0, 0x14000528e00, {0x101a91740, 0x14000a845b0})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:909 +0x8a0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x14000e30030, {0x101ad3080?, 0x14000eb1bc0?}, 0x140006d2af0)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xb78
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x101aefba0?, 0x14000e30030?}}, {0x101ad3080, 0x14000eb1bc0}, 0x0?)
github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf5to6server/tf5to6server.go:37 +0x58
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x101ad2fd8?, {0x101ad3080?, 0x14000eb1890?}, 0x140006d2aa0)
github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0x14000e50140, {0x101ad3080?, 0x140006ddf80?}, 0x14000f64070)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/tf6server/server.go:857 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x101a3e6e0?, 0x14000e50140}, {0x101ad3080, 0x140006ddf80}, 0x14000f64000, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400001d2c0, {0x101ae2900, 0x140001f51e0}, 0x14001062a20, 0x14000e267e0, 0x1026ff1d8, 0x0)
google.golang.org/grpc@v1.58.2/server.go:1376 +0xbe0
google.golang.org/grpc.(*Server).handleStream(0x1400001d2c0, {0x101ae2900, 0x140001f51e0}, 0x14001062a20, 0x0)
google.golang.org/grpc@v1.58.2/server.go:1753 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/grpc@v1.58.2/server.go:998 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.58.2/server.go:996 +0x16c

Error: The terraform-provider-snowflake_v0.76.0 plugin crashed!

Actual Behavior

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

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

goroutine 98 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake.SchemaObjectIdentifierFromQualifiedName({0x14000a98650?, 0x10136fbb4?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake/identifier.go:57 +0x178
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.CreateTableColumnMaskingPolicyApplication(0x0?, {0x101a91740?, 0x14000a845b0})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/table_column_masking_policy_application.go:52 +0x58
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x101ad3080?, {0x101ad3080?, 0x14000eb1da0?}, 0xd?, {0x101a91740?, 0x14000a845b0?})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:766 +0x134
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x14000e38540, {0x101ad3080, 0x14000eb1da0}, 0x140004fe5b0, 0x14000528e00, {0x101a91740, 0x14000a845b0})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:909 +0x8a0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x14000e30030, {0x101ad3080?, 0x14000eb1bc0?}, 0x140006d2af0)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xb78
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x101aefba0?, 0x14000e30030?}}, {0x101ad3080, 0x14000eb1bc0}, 0x0?)
github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf5to6server/tf5to6server.go:37 +0x58
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x101ad2fd8?, {0x101ad3080?, 0x14000eb1890?}, 0x140006d2aa0)
github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0x14000e50140, {0x101ad3080?, 0x140006ddf80?}, 0x14000f64070)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/tf6server/server.go:857 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x101a3e6e0?, 0x14000e50140}, {0x101ad3080, 0x140006ddf80}, 0x14000f64000, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400001d2c0, {0x101ae2900, 0x140001f51e0}, 0x14001062a20, 0x14000e267e0, 0x1026ff1d8, 0x0)
google.golang.org/grpc@v1.58.2/server.go:1376 +0xbe0
google.golang.org/grpc.(*Server).handleStream(0x1400001d2c0, {0x101ae2900, 0x140001f51e0}, 0x14001062a20, 0x0)
google.golang.org/grpc@v1.58.2/server.go:1753 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/grpc@v1.58.2/server.go:998 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.58.2/server.go:996 +0x16c

Error: The terraform-provider-snowflake_v0.76.0 plugin crashed!

Steps to Reproduce

resource "snowflake_table_column_masking_policy_application" "application0" {
table = "MYTABLE"
column = "MY_MASKING_COLUMN"
masking_policy = "MYDB.MYSCHEMA.MYMASKINGPOLICY"
}

run terraform plan - works as expected with changes made.

snowflake_table_column_masking_policy_application.application0 will be created

  • resource "snowflake_table_column_masking_policy_application" "application0" {
    • column = "MYCOLUMN"
    • id = (known after apply)
    • masking_policy = "MYDB.MYSCHEMA.MYMASKINGPOLICY"
    • table = "MYTABLE"
      }

Plan: 59 to add, 0 to change, 0 to destroy.

Terraform Apply:
When running terraform apply running into below error:

Enter a value: yes

snowflake_table_column_masking_policy_application.application32: Creating...
snowflake_table_column_masking_policy_application.application41: Creating...
snowflake_table_column_masking_policy_application.application14: Creating...
snowflake_table_column_masking_policy_application.application21: Creating...
snowflake_table_column_masking_policy_application.application40: Creating...
snowflake_table_column_masking_policy_application.application45: Creating...
snowflake_table_column_masking_policy_application.application43: Creating...
snowflake_table_column_masking_policy_application.application0: Creating...
snowflake_table_column_masking_policy_application.application58: Creating...
snowflake_table_column_masking_policy_application.application36: Creating...
.........
........

.........

│ Warning: Argument is deprecated

│ with provider["registry.terraform.io/snowflake-labs/snowflake"],
│ on providers.tf line 5, in provider "snowflake":
│ 5: region = var.snowflake_region

│ Specify the region as part of the account parameter

│ (and one more similar warning elsewhere)


│ Error: Request cancelled

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


│ Error: Request cancelled

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


│ Error: Plugin did not respond

│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.


│ Error: Plugin did not respond

│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.


│ Error: Request cancelled

│ The plugin6.(*GRPCProvider).ValidateResourceConfig 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 100 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake.SchemaObjectIdentifierFromQualifiedName({0x14000c8a9f0?, 0x10585fbb4?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake/identifier.go:57 +0x178
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.CreateTableColumnMaskingPolicyApplication(0x0?, {0x105f81740?, 0x14000680c30})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/table_column_masking_policy_application.go:52 +0x58
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x105fc3080?, {0x105fc3080?, 0x14000fccd50?}, 0xd?, {0x105f81740?, 0x14000680c30?})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:766 +0x134
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x140005dea80, {0x105fc3080, 0x14000fccd50}, 0x14000fa1380, 0x14000fca580, {0x105f81740, 0x14000680c30})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:909 +0x8a0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x14000b52048, {0x105fc3080?, 0x14000fccb70?}, 0x14000cc55e0)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xb78
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x105fdfba0?, 0x14000b52048?}}, {0x105fc3080, 0x14000fccb70}, 0x0?)
github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf5to6server/tf5to6server.go:37 +0x58
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x105fc2fd8?, {0x105fc3080?, 0x14000fcc840?}, 0x14000cc5590)
github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0x14000d36f00, {0x105fc3080?, 0x14000fc1e30?}, 0x14000fbc7e0)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/tf6server/server.go:857 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x105f2e6e0?, 0x14000d36f00}, {0x105fc3080, 0x14000fc1e30}, 0x14000fbc770, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400001f2c0, {0x105fd2900, 0x14000602d00}, 0x14000fc5200, 0x140005eae40, 0x106bef1d8, 0x0)
google.golang.org/grpc@v1.58.2/server.go:1376 +0xbe0
google.golang.org/grpc.(*Server).handleStream(0x1400001f2c0, {0x105fd2900, 0x14000602d00}, 0x14000fc5200, 0x0)
google.golang.org/grpc@v1.58.2/server.go:1753 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/grpc@v1.58.2/server.go:998 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.58.2/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.

How much impact is this issue causing?

High

Logs

No response

Additional Information

No response

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@paruchurij paruchurij added the bug Used to mark issues with provider's incorrect behavior label Sep 15, 2024
@sfc-gh-jmichalak sfc-gh-jmichalak added the resource:table_column_masking_policy_application Issue connected to the snowflake_table_column_masking_policy_application resource label Sep 16, 2024
@sfc-gh-jmichalak
Copy link
Collaborator

Hi @paruchurij 👋 The table needs to be provided as a fully qualified name (check docs). If you manage the referenced table, you can type

table = snowflake_table.table.fully_qualified_name

, otherwise

table = "\"database\".\"schema\".\"table\""

Note that we are currently reworking masking policies and this resource will be affected as well.

Also, I see that you use v0.76, and we suggest upgrading versions gradually (the newest one is 0.95).

@sfc-gh-jmichalak sfc-gh-jmichalak added general-usage General help/usage questions and removed bug Used to mark issues with provider's incorrect behavior labels Sep 16, 2024
@sfc-gh-jmichalak
Copy link
Collaborator

Hi 👋
As I wrote above, the fix is to use fully qualified names here.

FYI: We've reworked masking policies in v0.96 (the newest version is v0.97, we suggest migrating to this one with migration guides).

We're also planning to rework tables soon, and snowflake_table_column_masking_policy_application will be potentially deprecated in favor of setting masking policies in a column field, but we don't have more details here.

Closing the issue due to inactivity. Please create a new one if you believe this is a provider bug and the issue persists in the newest version of the provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general-usage General help/usage questions resource:table_column_masking_policy_application Issue connected to the snowflake_table_column_masking_policy_application resource
Projects
None yet
Development

No branches or pull requests

2 participants