diff --git a/src/deadline/job_attachments/asset_manifests/decode.py b/src/deadline/job_attachments/asset_manifests/decode.py index ac60434f..9ce239ea 100644 --- a/src/deadline/job_attachments/asset_manifests/decode.py +++ b/src/deadline/job_attachments/asset_manifests/decode.py @@ -49,8 +49,12 @@ def decode_manifest(manifest: str) -> BaseAssetManifest: version = ManifestVersion(document["manifestVersion"]) except ValueError: # Value of the manifest version is not one we know. + supported_versions = ", ".join( + [v.value for v in ManifestVersion if v != ManifestVersion.UNDEFINED] + ) raise ManifestDecodeValidationError( - f"Unknown manifest version: {document['manifestVersion']}" + f"Unknown manifest version: {document['manifestVersion']} " + f"(Currently supported Manifest versions: {supported_versions})" ) except KeyError: raise ManifestDecodeValidationError( diff --git a/test/unit/deadline_job_attachments/asset_manifests/test_decode.py b/test/unit/deadline_job_attachments/asset_manifests/test_decode.py index 6b7f3a18..dae05f6d 100644 --- a/test/unit/deadline_job_attachments/asset_manifests/test_decode.py +++ b/test/unit/deadline_job_attachments/asset_manifests/test_decode.py @@ -2,9 +2,11 @@ """ Tests for the asset_manifests.decode module """ from __future__ import annotations +from enum import Enum import json from dataclasses import dataclass +import re from typing import Any from unittest.mock import patch @@ -116,10 +118,42 @@ def test_decode_manifest_version_not_supported(): """ Test that a ManifestDecodeValidationError is raised if the manifest passed has a version that isn't valid. """ - with pytest.raises(ManifestDecodeValidationError, match="Unknown manifest version: 1900-06-06"): + with pytest.raises( + ManifestDecodeValidationError, + match=re.escape( + "Unknown manifest version: 1900-06-06 (Currently supported Manifest versions: 2023-03-03)" + ), + ): decode.decode_manifest('{"manifestVersion": "1900-06-06"}') +def test_decode_manifest_version_not_supported_when_multiple_versions_are_supported(): + """ + Test that a ManifestDecodeValidationError is raised with a descriptive error message if the manifest passed + has a version that isn't valid. In this test, the ManifestVersion class is mocked to simulate having multple + supported manifest versions. + """ + + class MockManifestVersion(str, Enum): + UNDEFINED = "UNDEFINED" + v2023_03_03 = "2023-03-03" + v2024_04_03 = "2024-04-03" + v2025_05_03 = "2025-05-03" + + with patch( + f"{deadline.__package__}.job_attachments.asset_manifests.decode.ManifestVersion", + new=MockManifestVersion, + ): + with pytest.raises( + ManifestDecodeValidationError, + match=re.escape( + "Unknown manifest version: 1900-06-06 " + "(Currently supported Manifest versions: 2023-03-03, 2024-04-03, 2025-05-03)" + ), + ): + decode.decode_manifest('{"manifestVersion": "1900-06-06"}') + + def test_decode_manifest_not_valid_manifest(): """ Test that a ManifestDecodeValidationError is raised if the manifest passed in is not valid.