fix: reject duplicate keys in execution catalogs
All checks were successful
ci / validate (push) Successful in 2m53s
All checks were successful
ci / validate (push) Successful in 2m53s
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a0726e-5232-73f2-aaca-2c05ceb62efb
This commit is contained in:
parent
f5eec5b23f
commit
863fab7a3b
5 changed files with 97 additions and 1 deletions
|
|
@ -226,3 +226,45 @@ def test_incompatible_profile_or_rein_is_rejected(
|
|||
|
||||
with pytest.raises(IncompatibleProfileError, match=match):
|
||||
ProfileCatalog(profiles, reins).resolve("harness.test@1.0.0")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", ["profile", "rein"])
|
||||
@pytest.mark.parametrize("nested", [False, True])
|
||||
def test_duplicate_catalog_keys_are_rejected(tmp_path, kind, nested):
|
||||
if kind == "profile":
|
||||
content = _profile()
|
||||
content += ("metadata:\n route: first\n route: second\n" if nested
|
||||
else "credential_route_refs: [first]\ncredential_route_refs: [second]\n")
|
||||
else:
|
||||
content = _rein()
|
||||
content = (content.replace("session_style: unattended",
|
||||
"session_style: interactive\n session_style: unattended")
|
||||
if nested else content + "status: disabled\n")
|
||||
_write(tmp_path, "duplicate.yaml", content)
|
||||
catalog = ProfileCatalog(profile_dir=tmp_path, rein_dir=tmp_path)
|
||||
with pytest.raises(ProfileError, match="duplicate YAML key"):
|
||||
catalog.profiles() if kind == "profile" else catalog.reins()
|
||||
|
||||
|
||||
def test_yaml_merge_cannot_override_catalog_values(tmp_path):
|
||||
_write(tmp_path, "profile.yaml", _profile(extra='''metadata:
|
||||
defaults: &defaults
|
||||
runtime: pinned
|
||||
selected:
|
||||
<<: *defaults
|
||||
runtime: different
|
||||
'''))
|
||||
with pytest.raises(ProfileError, match="duplicate YAML key"):
|
||||
ProfileCatalog(profile_dir=tmp_path).profiles()
|
||||
|
||||
|
||||
def test_nonoverlapping_yaml_merge_remains_supported(tmp_path):
|
||||
_write(tmp_path, "profile.yaml", _profile(extra='''metadata:
|
||||
defaults: &defaults
|
||||
runtime: pinned
|
||||
selected:
|
||||
<<: *defaults
|
||||
host: local
|
||||
'''))
|
||||
profile = ProfileCatalog(profile_dir=tmp_path).profiles()[("harness.test", "1.0.0")]
|
||||
assert profile.metadata["selected"] == {"runtime": "pinned", "host": "local"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue