The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(pricing): refuse an overrides file with a stray closing bracket after it
Claude856fea863341
diff --git a/cli/beacon/internal/pricing/overrides.go b/cli/beacon/internal/pricing/overrides.goindex a841b916..53a54c04 100644--- a/cli/beacon/internal/pricing/overrides.go+++ b/cli/beacon/internal/pricing/overrides.go@@ -219,7 +219,9 @@ func LoadOverrides(data []byte, catalog *Catalog) (*Overrides, error) {if err := dec.Decode(&file); err != nil {return nil, fmt.Errorf("parse: %w", err)}- if dec.More() {+ // More() reports false before a stray closing bracket or brace, so the end of input is+ // required explicitly: anything after the document, even a lone "]", is refused.+ if _, err := dec.Token(); err != io.EOF {return nil, fmt.Errorf("parse: trailing data after the document")}if file.Schema != OverridesSchema {@@ -470,7 +472,7 @@ func checkDuplicateKeys(data []byte) error {}if top != nil && top.object && top.expectKey {if tok == json.Delim('}') {- stack = stack[:len(stack)-1]+ stack = stack[:len(stack)-1] // top != nil, so the stack is not emptyvalueDone()continue}@@ -503,6 +505,11 @@ func checkDuplicateKeys(data []byte) error {case json.Delim('['):stack = append(stack, &frame{path: path})case json.Delim(']'):+ // The decoder refuses a "]" that closes nothing, but the stack is checked anyway so+ // a malformed file can only ever produce an error here, never a panic.+ if len(stack) == 0 {+ return fmt.Errorf("parse: unexpected ']'")+ }stack = stack[:len(stack)-1]valueDone()default:diff --git a/cli/beacon/internal/pricing/overrides_test.go b/cli/beacon/internal/pricing/overrides_test.goindex b4a1c9ad..8ae70389 100644--- a/cli/beacon/internal/pricing/overrides_test.go+++ b/cli/beacon/internal/pricing/overrides_test.go@@ -97,6 +97,11 @@ func TestOverridesRejectBadValuesNamingTheKey(t *testing.T) {{"alias is a model", `{"schema":"beacon.pricing.overrides/v1","models":{"m":{"input_usd_per_mtok":1,"output_usd_per_mtok":2}},"aliases":{"m":"gpt-5"}}`, `aliases["m"]: "m" is also a model in this file`},{"alias loose target", `{"schema":"beacon.pricing.overrides/v1","aliases":{"gw":"Claude-Sonnet-4-5"}}`, `target "Claude-Sonnet-4-5" is neither`},{"trailing data", `{"schema":"beacon.pricing.overrides/v1"} {}`, `trailing data`},+ // A stray closer after a complete document: the decoder's More() reports false in front+ // of it, so only an explicit end-of-input check refuses it.+ {"trailing bracket", `{"schema":"beacon.pricing.overrides/v1"}]`, `trailing data`},+ {"trailing brace", `{"schema":"beacon.pricing.overrides/v1"}}`, `trailing data`},+ {"lone bracket", `]`, `parse`},}for _, tc := range cases {t.Run(tc.name, func(t *testing.T) {