Repository navigation
FIX: reject duplicate YAML keys while preserving merge overrides - #3956
Merged
Richard Lundeen (richlundeen) merged 5 commits intoNov 17, 2026
Conversation
Validate explicit keys before merge expansion in the shared safe loader. Add both-backend regression coverage for seed imports, merges, aliases, and boolean/integer and NaN collisions. Fixes microsoft#3898
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the YAML loader’s duplicate-key validation changes.
No open issues 🎉
What changed in this PR
This PR updates PyRIT’s shared safe YAML loader to reject duplicate explicit mapping keys while preserving merge overrides, addressing #3898.
Changes:
- Validate keys before merge expansion and report duplicates with source locations.
- Preserve PyYAML’s merge precedence and safe-loading behavior.
- Add regression coverage for both loader backends, aliases, key collisions, and public seed imports.
| File | Description |
|---|---|
tests/unit/models/test_yaml_seed_loader.py |
Tests duplicate rejection and merge overrides through public seed imports. |
tests/unit/common/test_yaml_loadable.py |
Tests duplicate diagnostics and merge overrides for YAML-loadable objects. |
tests/unit/common/test_yaml_helper.py |
Adds backend coverage for duplicates, merges, aliases, key collisions, and safe loading. |
pyrit/common/yaml_helper.py |
Adds duplicate-key validation before standard merge expansion. |
Review effort: Balanced
Co-authored-by: Copilot App <[email protected]>
Richard Lundeen (richlundeen)
approved these changes
Nov 17, 2026
Richard Lundeen (richlundeen)
left a comment
Contributor
There was a problem hiding this comment.
Automated review completed. No blocking concerns remain. This review records source coverage; merging is handled separately.
Richard Lundeen (richlundeen)
self-requested a review
November 17, 2026 17:58
Share one libyaml-fallback import hook between the existing fallback test and the new both-backend fixture, and drop cases that only re-prove PyYAML scalar equality or repeat existing syntax and unsafe-tag tests. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Richard Lundeen (richlundeen)
approved these changes
Nov 17, 2026
Richard Lundeen (richlundeen)
left a comment
Contributor
There was a problem hiding this comment.
Automated review completed. No blocking concerns remain. This review records source coverage; merging is handled separately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Validate explicit keys before merge expansion in the shared safe loader. Add both-backend regression coverage for seed imports, merges, aliases, and boolean/integer and NaN collisions.
Fixes #3898
Description
Tests and Documentation