Skip to content

304: NewValidator - fix document model mutation#305

Open
litteratum wants to merge 1 commit into
pb33f:mainfrom
litteratum:fix-newvalidator-mutation-for-recursive-refs
Open

304: NewValidator - fix document model mutation#305
litteratum wants to merge 1 commit into
pb33f:mainfrom
litteratum:fix-newvalidator-mutation-for-recursive-refs

Conversation

@litteratum

@litteratum litteratum commented Jul 12, 2026

Copy link
Copy Markdown

Fix NewValidator's mutations for the document model.
It is just a guard around go-yaml.

The fix - clone YAML Node unconditionally in renderYAMLNodeForValidation.
I created a separate validator_model_mutation_test.go that tests all different combinations.

All tests pass.

The extra clone should not be a problem for performance because it is mostly done on initialization.

Fixes #304.

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.27%. Comparing base (f309f59) to head (449d178).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #305      +/-   ##
==========================================
- Coverage   98.27%   98.27%   -0.01%     
==========================================
  Files          75       75              
  Lines        9192     9191       -1     
==========================================
- Hits         9033     9032       -1     
  Misses        132      132              
  Partials       27       27              
Flag Coverage Δ
unittests 98.27% <100.00%> (-0.01%) ⬇️

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.

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.

NewValidator corrupts the shared document model when a schema has a recursive $ref target

1 participant