Skip to content

fix: compare enum entries by JSON value - #656

Open
CaliLuke wants to merge 1 commit into
pb33f:mainfrom
CaliLuke:codex/enum-value-equality
Open

CaliLuke wants to merge 1 commit into
pb33f:mainfrom
CaliLuke:codex/enum-value-equality

Conversation

@CaliLuke

Copy link
Copy Markdown
Contributor

CheckEnumForDuplicates compares only yaml.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 as 1 and "1", while missing numerically equal values such as 1 and 1.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=1 and go test -race ./utils -count=1 pass. 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#5 on 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.

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c4c4be7) to head (d696afb).

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     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CaliLuke
CaliLuke force-pushed the codex/enum-value-equality branch from 613a777 to d696afb Compare October 11, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant