From 1c32b6c423aa8188e8f5cf88e1b76892427b0a44 Mon Sep 17 00:00:00 2001 From: vickydotbat Date: Thu, 25 Jun 2026 22:11:50 +0200 Subject: [PATCH] fix(topdata): reject null condition groups --- internal/topdata/json_contract.go | 5 +---- internal/topdata/json_contract_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/internal/topdata/json_contract.go b/internal/topdata/json_contract.go index 8a3edcf..7da1222 100644 --- a/internal/topdata/json_contract.go +++ b/internal/topdata/json_contract.go @@ -97,10 +97,7 @@ 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 + return nil, fmt.Errorf("%s must be an array", name) } conditions, ok := raw.([]any) diff --git a/internal/topdata/json_contract_test.go b/internal/topdata/json_contract_test.go index 82e043e..1525d48 100644 --- a/internal/topdata/json_contract_test.go +++ b/internal/topdata/json_contract_test.go @@ -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{