cockroachdb / terraform-provider-cockroach

Terraform provider for CockroachDB Cloud
Apache License 2.0
57 stars 12 forks source link

Error messages for invalid conditions with CRDB Terraform Provider #11

Closed alistair-roacher closed 2 years ago

alistair-roacher commented 2 years ago

If I attempt to explicitly specify the version for a Serverless cluster I get the following error:

Attempting to create a serverless cluster with an explicit version ("v22.1.1") ╷ │ Error: Provider produced invalid plan │ │ Provider "registry.terraform.io/hashicorp/cockroach" planned an invalid value for cockroach_cluster.cockroach.cockroach_version: planned value │ cty.NullVal(cty.String) does not match config value cty.StringVal("v22.1.1"). │ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵ This should return a more descriptive error message.

alistair-roacher commented 2 years ago

Other conditions are captured correctly but could still benefit from some tidying up. For example:

Error: Error creating sql user │ │ with cockroach_sql_user.cockroach, │ on main.tf line 14, in resource "cockroach_sql_user" "cockroach": │ 14: resource "cockroach_sql_user" "cockroach" { │ │ "code": 3, │ "message": "invalid argument: invalid field Password: must be at least 12 characters and less than 501", │ "details": []

To be consistent with other Terraform providers the error message should look something like this:

╷ │ Error: Error creating sql user: invalid argument: invalid field Password: must be at least 12 characters and less than 501 │ │ with cockroach_sql_user.cockroach, │ on main.tf line 14, in resource "cockroach_sql_user" "cockroach": │ 14: resource "cockroach_sql_user" "cockroach" { │

alistair-roacher commented 2 years ago

Just to clarify - my point about the error message for "invalid plan" is that the text should be much clearer - i.e. not contain the phrase "This is a bug in the provider" and to not mention internal structures such as "cty.NullVal(cty.String)"

prafull01 commented 2 years ago

Reopening this. Attached the PR to wrong issue. The issue is about the user should able to specify the cockroach version while creating the cluster