terraform-provider-snowflake icon indicating copy to clipboard operation
terraform-provider-snowflake copied to clipboard

Error: Failed to decode resource from state

Open jooel-korpi-caruna opened this issue 2 years ago • 4 comments

Provider Version

0.53.0

Terraform Version

1.3.6

Describe the bug

After migrating from provider version 0.47.0 to 0.53.0, the resource "snowflake_task" "tasks" started to give:

│ Error: Failed to decode resource from state
│
│ Error decoding "snowflake_task.tasks[\"...\"]" from previous state: missing expected [

and

│ Error: missing expected [
│
│   with snowflake_task.tasks["..."],
│   on tasks.tf line 1, in resource "snowflake_task" "tasks":
│    1: resource "snowflake_task" "tasks" {

which seem like the same error.

Expected behavior That terraform apply would work as before and migration of state format was taken into account.

Code samples and commands

terraform apply

Additional context

Reason for updating version was adding warehouse type and there was changes. No changes to the task side.

jooel-korpi-caruna avatar Dec 13 '22 11:12 jooel-korpi-caruna

good to know, before we upgrade to the latest and greatest :-)

funes79 avatar Dec 19 '22 11:12 funes79

I have stumbled across this same issue today. We have upgraded provider from 0.37.0 to 0.51.0 and as soon as I did so the output from terraform plan included 33 occurrences of:

│ Warning: Failed to decode resource from state │ │ Error decoding "snowflake_task.redacted" from prior │ state: missing expected [

│ Error: missing expected [ │ │ with snowflake_task.redacted, │ on file.tf line 95, in resource "snowflake_task" "redacted": │ 95: after = snowflake_task.redacted.name

Disappointed to stumble across this issue and discover that there is no-one assigned to it 4 months after it was first posted 😞

@jooel-korpi-caruna did you figure out a workaround?

jamiekt avatar Apr 21 '23 16:04 jamiekt

I am having the same issue in 0.89.0

jacobRiehl avatar May 03 '24 18:05 jacobRiehl

Hey @jooel-korpi-caruna @funes79 @jamiekt @jacobRiehl. Thanks for reaching out to us.

In the newer provider versions, we avoid such situations. We have also introduced the https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#migration-guide to help with the transition in newer versions.

It's always possible to remove a resource from the state and reimport it (described in https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/resource_migration.md) and it should be possible to treat it as a workaround in the ancient provider versions.

Please bear in mind that we are still in the pre-stable version (0.x.x; check the disclaimer in https://github.com/Snowflake-Labs/terraform-provider-snowflake?tab=readme-ov-file#snowflake-terraform-provider) and we do not provide backward bugfixes. We always recommend bumping to the newest version.

@jacobRiehl, please create a new issue with a proper description since your issue touches on the latest provider version.

sfc-gh-asawicki avatar May 06 '24 11:05 sfc-gh-asawicki