Skip to content

Commit 151d354

Browse files
nicolehaugenCopilot
andcommitted
fix: enforce strict artifact json
Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent d3da088 commit 151d354

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎src/specify_cli/artifacts/catalog.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def get_contribution_info(self, lookup_id: str) -> dict[str, Any]:
438438

439439
contribution, manifest_path, source_path = resolved
440440
try:
441-
json.dumps(contribution)
441+
json.dumps(contribution, allow_nan=False)
442442
except (TypeError, ValueError) as exc:
443443
raise ArtifactResolutionError() from exc
444444
return {

‎tests/test_artifact_command.py‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,19 +1074,32 @@ def test_lookup_json_rejects_unknown_contribution(
10741074
"error": f"unknown contribution {lookup_id}"
10751075
}
10761076

1077+
@pytest.mark.parametrize(
1078+
"manifest_value",
1079+
[
1080+
date(2026, 1, 1),
1081+
float("nan"),
1082+
float("inf"),
1083+
float("-inf"),
1084+
],
1085+
ids=["date", "nan", "positive-infinity", "negative-infinity"],
1086+
)
10771087
def test_lookup_json_rejects_non_json_manifest_value(
1078-
self, spec_kit_project: Path, monkeypatch: pytest.MonkeyPatch
1088+
self,
1089+
spec_kit_project: Path,
1090+
monkeypatch: pytest.MonkeyPatch,
1091+
manifest_value: object,
10791092
):
10801093
monkeypatch.chdir(spec_kit_project)
10811094
install_preset(
10821095
spec_kit_project,
1083-
"dated-contribution",
1096+
"non-json-contribution",
10841097
{
10851098
"templates": [
10861099
{
10871100
"type": "template",
1088-
"name": "dated-contribution",
1089-
"released": date(2026, 1, 1),
1101+
"name": "non-json-contribution",
1102+
"extra": manifest_value,
10901103
}
10911104
]
10921105
},
@@ -1097,7 +1110,7 @@ def test_lookup_json_rejects_non_json_manifest_value(
10971110
[
10981111
"artifact",
10991112
"lookup",
1100-
"preset:dated-contribution:template:dated-contribution",
1113+
"preset:non-json-contribution:template:non-json-contribution",
11011114
"--json",
11021115
],
11031116
)

0 commit comments

Comments
 (0)