Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit358b641

Browse files
authored
chore: skip parameter resolution for dynamic params (#17922)
Pass through the user input as is. The previous code only passed throughparameters that existed in the db (static params). This would omitconditional params.Validation is enforced by the dynamic params websocket, so validation atthis point is not required.
1 parentfe733af commit358b641

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

‎coderd/wsbuilder/wsbuilder.go

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -593,30 +593,42 @@ func (b *Builder) getParameters() (names, values []string, err error) {
593593
returnnil,nil,BuildError{http.StatusBadRequest,"Unable to build workspace with unsupported parameters",err}
594594
}
595595

596+
ifb.dynamicParametersEnabled {
597+
// Dynamic parameters skip all parameter validation.
598+
// Pass the user's input as is.
599+
// TODO: The previous behavior was only to pass param values
600+
// for parameters that exist. Since dynamic params can have
601+
// conditional parameter existence, the static frame of reference
602+
// is not sufficient. So assume the user is correct, or pull in the
603+
// dynamic param code to find the actual parameters.
604+
for_,value:=rangeb.richParameterValues {
605+
names=append(names,value.Name)
606+
values=append(values,value.Value)
607+
}
608+
b.parameterNames=&names
609+
b.parameterValues=&values
610+
returnnames,values,nil
611+
}
612+
596613
resolver:= codersdk.ParameterResolver{
597614
Rich:db2sdk.WorkspaceBuildParameters(lastBuildParameters),
598615
}
616+
599617
for_,templateVersionParameter:=rangetemplateVersionParameters {
600618
tvp,err:=db2sdk.TemplateVersionParameter(templateVersionParameter)
601619
iferr!=nil {
602620
returnnil,nil,BuildError{http.StatusInternalServerError,"failed to convert template version parameter",err}
603621
}
604622

605-
varvaluestring
606-
if!b.dynamicParametersEnabled {
607-
varerrerror
608-
value,err=resolver.ValidateResolve(
609-
tvp,
610-
b.findNewBuildParameterValue(templateVersionParameter.Name),
611-
)
612-
iferr!=nil {
613-
// At this point, we've queried all the data we need from the database,
614-
// so the only errors are problems with the request (missing data, failed
615-
// validation, immutable parameters, etc.)
616-
returnnil,nil,BuildError{http.StatusBadRequest,fmt.Sprintf("Unable to validate parameter %q",templateVersionParameter.Name),err}
617-
}
618-
}else {
619-
value=resolver.Resolve(tvp,b.findNewBuildParameterValue(templateVersionParameter.Name))
623+
value,err:=resolver.ValidateResolve(
624+
tvp,
625+
b.findNewBuildParameterValue(templateVersionParameter.Name),
626+
)
627+
iferr!=nil {
628+
// At this point, we've queried all the data we need from the database,
629+
// so the only errors are problems with the request (missing data, failed
630+
// validation, immutable parameters, etc.)
631+
returnnil,nil,BuildError{http.StatusBadRequest,fmt.Sprintf("Unable to validate parameter %q",templateVersionParameter.Name),err}
620632
}
621633

622634
names=append(names,templateVersionParameter.Name)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp