spacelift-io / terraform-provider-spacelift

Terraform provider to interact with Spacelift
MIT License
76 stars 29 forks source link

Poor error message when importing a non-existent stack ID #405

Closed adamconnelly closed 1 year ago

adamconnelly commented 1 year ago

Running a terraform import with a stack ID that doesn't exist results in an obscure error message from Terraform:

terraform import spacelift_stack.this non-existent-stack
spacelift_stack.this: Importing from ID "non-existent-stack"...
╷
│ Error: The provider returned a resource missing an identifier during ImportResourceState. This is generally a bug in the resource implementation for import. Resource import code should not call d.SetId("") or create an empty ResourceData. If the resource is missing, instead return an error. Please report this to the provider developers.

This is caused by us setting the ID to an empty string and not returning an error if the stack doesn't exist. We can detect this and give users a better error message.

adamconnelly commented 1 year ago

We've updated the provider to return a better error message. This will be fixed in the next release of the provider.