Skip to content

Commit a982dfb

Browse files
committed
fix: EnvironmentActions validation edge case
The EnvironmentActions oneOf validator assumed that actions was a dictionary. If the template being validated had an environment action of any other type then an AttributeError would throw Signed-off-by: Preston Tamkin <845970+prestomation@users.noreply.github.com>
1 parent 9b0265e commit a982dfb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/openjd/model/v2023_09/_model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ class EnvironmentActions(OpenJDModel_v2023_09):
351351
@classmethod
352352
def _requires_oneof(cls, values: dict[str, Any]) -> dict[str, Any]:
353353
"""A validator that runs on the model data before parsing."""
354+
if not isinstance(values, dict):
355+
raise ValueError("Expected a dictionary of values")
356+
354357
on_enter = values.get("onEnter")
355358
on_exit = values.get("onExit")
356359
if on_enter is None and on_exit is None:

test/openjd/model/v2023_09/test_template_variables.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,17 @@ def test_job_template_variables_parse_success(data: dict[str, Any]) -> None:
11281128
2, # Validation of Job Foo & Task Foo
11291129
id="all parameter symbols are defined when validation errors",
11301130
),
1131+
pytest.param(
1132+
{
1133+
"specificationVersion": "jobtemplate-2023-09",
1134+
"name": "Foo",
1135+
"parameterDefinitions": [FOO_PARAMETER_STRING],
1136+
"steps": [STEP_TEMPLATE_FOO],
1137+
"jobEnvironments": [{"name": "VariableEnv", "script": {"actions": []}}],
1138+
},
1139+
1,
1140+
id="jobEnvironments.script.actions needs to be a dict",
1141+
),
11311142
)
11321143

11331144

0 commit comments

Comments
 (0)