Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #656 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 309 310 +1
Lines 39213 39286 +73
=========================================
+ Hits 39213 39286 +73
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
613a777 to
d696afb
Compare
daveshanley
left a comment
There was a problem hiding this comment.
Solid. Comparing by JSON value fixes the array/object false positives properly, and interning through aliases is smart. One thing to fix before merge (inline).
Heads up for vacuum: 1 and "1" stop being duplicates. That's correct.
| return "", false | ||
| } | ||
| return "n" + value.String(), true | ||
| case "!!float": |
There was a problem hiding this comment.
big.Rat expands the exponent in full. 1e999999 costs ~50ms and builds a 1MB key per value, and the key stays in the map. vacuum runs this on specs we don't control, so a few thousand of those in an enum pins a CPU and eats GBs.
Cap it before parsing. Anything outside float64 range (exponent beyond ±400 or so) can return "", false or fall back to the raw text. Same treatment for absurdly long !!int literals.
CheckEnumForDuplicatescompares onlyyaml.Node.Value. Sequence and mapping nodes have empty scalar values, so distinct arrays and objects are reported as duplicates. The same comparison conflates values such as1and"1", while missing numerically equal values such as1and1.0.Compare JSON values recursively, preserving array order and ignoring object member order. Keep scalar types distinct, normalize numeric values exactly, and return the original nodes for each duplicate occurrence. Resolve YAML aliases while rejecting cyclic and non-JSON values from this comparison.
The regression tests cover arrays, objects, nested values, mixed scalar types, equivalent numeric forms, integers beyond floating-point precision, aliases, malformed nodes, and cyclic inputs. The original implementation fails the value regression matrix; the corrected implementation passes it.
Validation:
go test ./utils -count=1andgo test -race ./utils -count=1pass. Caller-level regression tests using the duplicate-enum rule pass for OpenAPI 3.1 and 3.2 documents in both JSON and YAML.The full suite passes except
json/FuzzAppendJSONString/seed#5on Go 1.27.2: its invalid-UTF-8 expectation differs from the standard JSON encoder. The same failure reproduces on unchanged v0.41.6; this patch does not modify the JSON writer.