Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion artifactManifest/artifact_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _load_expected(manifest_path: Path) -> dict[str, ManifestFile]:
raise ManifestError(f"cannot read manifest {manifest_path}: {exc}") from exc
if not isinstance(payload, dict):
raise ManifestError("manifest must contain a JSON object")
if payload.get("schema_version") != SCHEMA_VERSION:
if type(payload.get("schema_version")) is not int or payload["schema_version"] != SCHEMA_VERSION:
raise ManifestError(
f"unsupported schema_version: {payload.get('schema_version')!r}"
)
Expand Down
10 changes: 10 additions & 0 deletions artifactManifest/tests/test_artifact_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,13 @@ def test_invalid_utf8_manifest_reports_error_without_traceback(tmp_path: Path, c
captured = capsys.readouterr()
assert "cannot read manifest" in captured.err
assert "Traceback" not in captured.err


@pytest.mark.parametrize("version", [True, 1.0, "1", None])
def test_schema_version_requires_integer(tmp_path: Path, version: object) -> None:
root = tmp_path / "artifact"
root.mkdir()
manifest = tmp_path / "manifest.json"
manifest.write_text(json.dumps({"schema_version": version, "root": ".", "files": []}), encoding="utf-8")
with pytest.raises(artifact_manifest.ManifestError, match="unsupported schema_version"):
artifact_manifest.verify_manifest(root, manifest)
Loading