Skip to content

Reject YAML keys that collide after JSON conversion - #20

Open
Aryangupta-05 wants to merge 1 commit into
oasdiff:mainfrom
Aryangupta-05:fix/reject-colliding-json-map-keys
Open

Aryangupta-05 wants to merge 1 commit into
oasdiff:mainfrom
Aryangupta-05:fix/reject-colliding-json-map-keys

Conversation

@Aryangupta-05

Copy link
Copy Markdown

YAML scalar keys can be distinct in the decoded map but convert to the same JSON member name. For example, 0 and .0 both become "0". The conversion currently overwrites one value according to Go map iteration order, so enabling origin tracking can change the decoded document.

Reject a collision before assigning to the converted string-keyed map. This intentionally rejects ambiguous inputs that previously lost data nondeterministically; distinct keys keep their existing behavior.

Tests cover the exact kin-openapi CI fuzz input, integer/string and boolean/string collisions, nested and sequence mappings, origin tracking on/off, YAMLToJSON, and noncolliding numeric/string controls.

Validation: full dependency suite with go test -race ./..., vet, module verification and golangci-lint 2.14.0 pass on Windows/amd64, Go 1.27.3. Kin-openapi's exact failing seed 13a4f64947658e0d passes 100 repetitions with this dependency fix supplied through an isolated alternate modfile. A fresh 60-second FuzzLoadWithOrigins budget also passes (29,262 executions). No change to kin-openapi's published branch or dependency files is included.

This is a separate dependency fix for https://github.com/getkin/kin-openapi/actions/runs/41282664333/job/124777580434. It does not by itself change that PR's CI result: the dependency must be reviewed, released and adopted first.

Signed-off-by: Aryan <aryangupta050903@gmail.com>
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