fix(topdata): reject null condition groups
This commit is contained in:
@@ -97,10 +97,7 @@ func parseGlobalConditionGroups(injection map[string]any) (globalConditionGroups
|
|||||||
|
|
||||||
func parseGlobalConditionList(name string, raw any, requireNonEmpty bool) ([]globalCondition, error) {
|
func parseGlobalConditionList(name string, raw any, requireNonEmpty bool) ([]globalCondition, error) {
|
||||||
if raw == nil {
|
if raw == nil {
|
||||||
if requireNonEmpty {
|
return nil, fmt.Errorf("%s must be an array", name)
|
||||||
return nil, fmt.Errorf("%s must be an array", name)
|
|
||||||
}
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conditions, ok := raw.([]any)
|
conditions, ok := raw.([]any)
|
||||||
|
|||||||
@@ -98,6 +98,20 @@ func TestParseGlobalConditionGroups(t *testing.T) {
|
|||||||
UnlessPresent: []globalCondition{},
|
UnlessPresent: []globalCondition{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "require present null is rejected",
|
||||||
|
injection: map[string]any{
|
||||||
|
"require_present": nil,
|
||||||
|
},
|
||||||
|
wantError: "require_present must be an array",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "unless present null is rejected",
|
||||||
|
injection: map[string]any{
|
||||||
|
"unless_present": nil,
|
||||||
|
},
|
||||||
|
wantError: "unless_present must be an array",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "any present must be array",
|
name: "any present must be array",
|
||||||
injection: map[string]any{
|
injection: map[string]any{
|
||||||
|
|||||||
Reference in New Issue
Block a user