Skip to content

Commit 41b2494

Browse files
authored
flx: handle None environments correctly (#254)
fix: handle None value for environment field in EnvironmentTemplate Signed-off-by: Stephen Crowe <[email protected]>
1 parent b6ead87 commit 41b2494

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/openjd/model/v2023_09/_model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,8 @@ class Environment(OpenJDModel_v2023_09):
10551055
@model_validator(mode="before")
10561056
@classmethod
10571057
def _validate_has_script_or_variables(cls, values: dict[str, Any]) -> dict[str, Any]:
1058+
if not isinstance(values, dict):
1059+
raise ValueError("Environment must be a mapping.")
10581060
if values.get("script") is None and values.get("variables") is None:
10591061
raise ValueError("Environment must have either a script or variables.")
10601062
return values

test/openjd/model/v2023_09/test_environment_template.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ def test_parse_success(self, data: dict[str, Any]) -> None:
102102
1,
103103
id="missing spec ver",
104104
),
105+
pytest.param(
106+
{
107+
"specificationVersion": "environment-2023-09",
108+
"environment": None,
109+
},
110+
1,
111+
id="environment is None",
112+
),
105113
#
106114
pytest.param(
107115
{

0 commit comments

Comments
 (0)