mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
job parsing: fix panic when variable validation is missing condition (#16018)
This commit is contained in:
3
.changelog/16018.txt
Normal file
3
.changelog/16018.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
parser: Fixed a panic in the job spec parser when a variable validation block was missing its condition
|
||||
```
|
||||
@@ -95,6 +95,17 @@ func (v *Variable) validateValue(val VariableAssignment) (diags hcl.Diagnostics)
|
||||
for _, validation := range v.Validations {
|
||||
const errInvalidCondition = "Invalid variable validation result"
|
||||
|
||||
if validation.Condition == nil {
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: "Invalid variable validation specification",
|
||||
Detail: "validation requires a condition.",
|
||||
Subject: validation.DeclRange.Ptr(),
|
||||
EvalContext: hclCtx,
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
result, moreDiags := validation.Condition.Value(hclCtx)
|
||||
diags = append(diags, moreDiags...)
|
||||
if !result.IsKnown() {
|
||||
|
||||
Reference in New Issue
Block a user