Skip to content

Commit 92c9992

Browse files
committed
fix: panic
1 parent 00533fa commit 92c9992

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

coderd/wsbuilder/wsbuilder.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ func (b *Builder) getProvisionerTags() (map[string]string, error) {
675675

676676
evalCtx := buildParametersEvalContext(parameterNames, parameterValues)
677677
for _, workspaceTag := range workspaceTags {
678-
expr, diags := hclsyntax.ParseExpression([]byte(workspaceTag.Value), "partial.hcl", hcl.InitialPos)
678+
expr, diags := hclsyntax.ParseExpression([]byte(workspaceTag.Value), "expression.hcl", hcl.InitialPos)
679679
if diags.HasErrors() {
680680
return nil, BuildError{http.StatusBadRequest, "failed to parse workspace tag value", xerrors.Errorf(diags.Error())}
681681
}
@@ -702,6 +702,11 @@ func buildParametersEvalContext(names, values []string) *hcl.EvalContext {
702702
"value": cty.StringVal(values[i]),
703703
})
704704
}
705+
706+
if len(m) == 0 {
707+
return nil // otherwise, panic: must not call MapVal with empty map
708+
}
709+
705710
return &hcl.EvalContext{
706711
Variables: map[string]cty.Value{
707712
"data": cty.MapVal(map[string]cty.Value{

0 commit comments

Comments
 (0)