From 5e36547a1cfedf4ea32e0c8877d6e0eeadcbbb0a Mon Sep 17 00:00:00 2001 From: claw Date: Tue, 12 May 2026 14:51:49 -0700 Subject: [PATCH] fix: correct comment accuracy and improve trailing-content check clarity - Fix validated map comment: says 'minimum depth' but stores the maximum depth at which a node was validated (overwritten on deeper visits). - Replace dec.More() with explicit dec.Decode check for trailing JSON content. More() is documented for use inside arrays/objects; the explicit EOF check is clearer at the top-level stream. --- review/persona.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/review/persona.go b/review/persona.go index c9c71cb..9a42884 100644 --- a/review/persona.go +++ b/review/persona.go @@ -152,7 +152,7 @@ func parsePersona(data []byte, source string) (*Persona, error) { // Without this check, input like `{"name":"x"}garbage` would // silently succeed because Decoder stops after one object. var dummy json.RawMessage - if dec.More() || dec.Decode(&dummy) != io.EOF { + if err2 := dec.Decode(&dummy); err2 != io.EOF { err = fmt.Errorf("unexpected trailing content after JSON object") } } @@ -205,7 +205,7 @@ func unmarshalYAMLWithDepthLimit(data []byte, out any, maxDepth int) error { // checkYAMLDepth recursively checks that YAML AST nodes don't exceed the depth // limit or the total node count limit. It uses two tracking maps: -// - validated: maps each node to the minimum depth at which it was previously +// - validated: maps each node to the maximum depth at which it was previously // checked. If a node is revisited at a deeper depth (e.g., via an alias), // we re-check it to ensure the combined effective depth doesn't exceed limits. // - visiting: per-path recursion stack for true cycle detection. A node on the