fix(topdata): reject null condition groups

This commit is contained in:
2026-06-25 22:11:50 +02:00
parent 18ffac6317
commit 1c32b6c423
2 changed files with 15 additions and 4 deletions
-3
View File
@@ -97,11 +97,8 @@ func parseGlobalConditionGroups(injection map[string]any) (globalConditionGroups
func parseGlobalConditionList(name string, raw any, requireNonEmpty bool) ([]globalCondition, error) {
if raw == nil {
if requireNonEmpty {
return nil, fmt.Errorf("%s must be an array", name)
}
return nil, nil
}
conditions, ok := raw.([]any)
if !ok {
+14
View File
@@ -98,6 +98,20 @@ func TestParseGlobalConditionGroups(t *testing.T) {
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",
injection: map[string]any{