💫 Toolkit to help you get started with SDD or any other process!
fix: normalize non-UTF-8 integration manifests (#3862)
Marsel Safin227b4f5e11ec
diff --git a/src/specify_cli/integrations/manifest.py b/src/specify_cli/integrations/manifest.pyindex ac799ebee..ef2a9fc89 100644--- a/src/specify_cli/integrations/manifest.py+++ b/src/specify_cli/integrations/manifest.py@@ -471,6 +471,10 @@ class IntegrationManifest:path = inst.manifest_pathtry:data = json.loads(path.read_text(encoding="utf-8"))+ except UnicodeDecodeError as exc:+ raise ValueError(+ f"Integration manifest at {path} is not valid UTF-8"+ ) from excexcept json.JSONDecodeError as exc:raise ValueError(f"Integration manifest at {path} contains invalid JSON"diff --git a/tests/integrations/test_manifest.py b/tests/integrations/test_manifest.pyindex 6c09d2e36..25188ef9c 100644--- a/tests/integrations/test_manifest.py+++ b/tests/integrations/test_manifest.py@@ -375,6 +375,14 @@ class TestManifestLoadValidation:with pytest.raises(ValueError, match="invalid JSON"):IntegrationManifest.load("bad", tmp_path)+ def test_load_non_utf8_json_raises_value_error(self, tmp_path):+ path = tmp_path / ".specify" / "integrations" / "bad.manifest.json"+ path.parent.mkdir(parents=True)+ path.write_bytes(b"\xff\xfe")++ with pytest.raises(ValueError, match="valid UTF-8"):+ IntegrationManifest.load("bad", tmp_path)+def test_load_filters_recovered_files_not_in_files(self, tmp_path):# Finding B (Round-9): a recovered_files entry referencing a path# not present in files indicates an internally-inconsistent manifest