- Notifications
You must be signed in to change notification settings - Fork3
Commit269046e
authored
fix: skip validating unknown versions list (#115)
This fixes an error when setting the `versions` attribute of a`coderd_template` using a variable, e.g:```terraformresource "coderd_template" "dev" { versions = var.template_versions [...]}variable "template_versions" { description = "Versions of the Coder template." default = [ { directory = "modules/" active = true tf_vars = [ { name = "coder_instance" value = "prod" } ] } ]}```would return:```│ Error: Value Conversion Error││ with module.devcontainers.coderd_template.dev,│ An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to the provider│ developer:││ Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types` package type or a custom type that handles│ unknown values.││ Path:│ Target Type: []provider.TemplateVersion│ Suggested Type: basetypes.ListValue```This error was caused by attempting to validate the versions listwithout checking if the config value is unknown. Normally, this valueshould never be unknown, as it's required, but it looks like Terraformdoes a configuration validation *before* variables are populated, aswell as after.To confirm this is the correct solution, we see that all the defaultvalidators perform the same null & unknown checks, e.g:```gofunc (v lengthBetweenValidator) ValidateString(ctx context.Context, request validator.StringRequest, response *validator.StringResponse) {if request.ConfigValue.IsNull() || request.ConfigValue.IsUnknown() {return}...}```1 parent7bbfc7f commit269046e
1 file changed
+4
-0
lines changedLines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
888 | 888 |
| |
889 | 889 |
| |
890 | 890 |
| |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
891 | 895 |
| |
892 | 896 |
| |
893 | 897 |
| |
|
0 commit comments
Comments
(0)