fix: correct comment accuracy and improve trailing-content check clarity
PR Ready Gate / clear-labels (pull_request) Successful in 1s
CI / test (pull_request) Successful in 19s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 34s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m10s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m47s

- 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.
This commit is contained in:
claw
2026-05-12 14:51:49 -07:00
parent 5cedeee9f4
commit 493349e11a
+2 -2
View File
@@ -152,7 +152,7 @@ func parsePersona(data []byte, source string) (*Persona, error) {
// Without this check, input like `{"name":"x"}garbage` would // Without this check, input like `{"name":"x"}garbage` would
// silently succeed because Decoder stops after one object. // silently succeed because Decoder stops after one object.
var dummy json.RawMessage 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") 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 // checkYAMLDepth recursively checks that YAML AST nodes don't exceed the depth
// limit or the total node count limit. It uses two tracking maps: // 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), // 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. // 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 // - visiting: per-path recursion stack for true cycle detection. A node on the