fix: prompt when parameter options are incompatible (#9247)

This commit is contained in:
Marcin Tojek
2023-08-23 18:18:38 +02:00
committed by GitHub
parent 8bfa312905
commit e845deaa89
15 changed files with 219 additions and 62 deletions

3
coderd/apidoc/docs.go generated
View File

@ -8440,11 +8440,9 @@ const docTemplate = `{
"codersdk.JobErrorCode": {
"type": "string",
"enum": [
"MISSING_TEMPLATE_PARAMETER",
"REQUIRED_TEMPLATE_VARIABLES"
],
"x-enum-varnames": [
"MissingTemplateParameter",
"RequiredTemplateVariables"
]
},
@ -8978,7 +8976,6 @@ const docTemplate = `{
},
"error_code": {
"enum": [
"MISSING_TEMPLATE_PARAMETER",
"REQUIRED_TEMPLATE_VARIABLES"
],
"allOf": [

View File

@ -7572,11 +7572,8 @@
},
"codersdk.JobErrorCode": {
"type": "string",
"enum": ["MISSING_TEMPLATE_PARAMETER", "REQUIRED_TEMPLATE_VARIABLES"],
"x-enum-varnames": [
"MissingTemplateParameter",
"RequiredTemplateVariables"
]
"enum": ["REQUIRED_TEMPLATE_VARIABLES"],
"x-enum-varnames": ["RequiredTemplateVariables"]
},
"codersdk.License": {
"type": "object",
@ -8070,7 +8067,7 @@
"type": "string"
},
"error_code": {
"enum": ["MISSING_TEMPLATE_PARAMETER", "REQUIRED_TEMPLATE_VARIABLES"],
"enum": ["REQUIRED_TEMPLATE_VARIABLES"],
"allOf": [
{
"$ref": "#/definitions/codersdk.JobErrorCode"

View File

@ -525,7 +525,7 @@ func (b *Builder) getParameters() (names, values []string, err error) {
// At this point, we've queried all the data we need from the database,
// so the only errors are problems with the request (missing data, failed
// validation, immutable parameters, etc.)
return nil, nil, BuildError{http.StatusBadRequest, err.Error(), err}
return nil, nil, BuildError{http.StatusBadRequest, fmt.Sprintf("Unable to validate parameter %q", templateVersionParameter.Name), err}
}
names = append(names, templateVersionParameter.Name)
values = append(values, value)