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

parameter validation errors should happen in the wizard instead of the workspace build

Open matifali opened this issue 10 months ago • 3 comments

Given a parameter with a choice, when creating a Workspace, if the user deletes the default value in the field, in this example from "0" to ""

data "coder_parameter" "home_data_disk_size" {
  type        = "number"
  name        = "Additional Home Data Volume Size"
  mutable     = true
  default     = 0
  validation {
    min       = 0
    max       = 2048
    monotonic = "increasing"
  }
}

You get this error when the Terraform runs:

Error: value "" is not a number
on .terraform/modules/platform_eng/data.tf line 487, in data "coder_parameter" "home_data_disk_size":
  487: data "coder_parameter" "home_data_disk_size" {

I believe this should be validated when in the wizard instead. Either that or provide something like a boolean attribute in the coder_parameter schema for an option like non_empty

matifali avatar Jan 29 '25 10:01 matifali

This is an excellent use case for our coder preview engine. We have a lot of areas to cover with error handling but we want to expose these earlier. Both in the workspace creation screen and when testing templates locally.

This becomes a larger headache as we allow parameter conditionality.

stirby avatar Mar 06 '25 18:03 stirby

@Emyrk, would this be handled now with dynamic parameters?

matifali avatar May 27 '25 05:05 matifali

@matifali If I understand correctly, then yes.

Dynamic params will show an empty form input, and have a required mark. The user must provide a value before submitting.

Emyrk avatar May 27 '25 14:05 Emyrk