Skip to content

Commit

Permalink
feat: include "signature", "name" in DSL errors about conflicting tem…
Browse files Browse the repository at this point in the history
…plate names (#365)

Resolves https://github.ibm.com/st4sd/st4sd-runtime-core/issues/364
Signed-off-by: Vassilis Vassiladis <[email protected]>
  • Loading branch information
VassilisVassiliadis authored and GitHub Enterprise committed Sep 20, 2024
1 parent e92ff9c commit 59a2d42
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/experiment/model/frontends/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ class Action(str, enum.Enum):
template_type = known_template_names[temp.signature.name]
dsl_error.underlying_errors.append(
experiment.model.errors.DSLInvalidFieldError(
location=[kind.lower() + "s", idx],
location=[kind.lower() + "s", idx, "signature", "name"],
underlying_error=KeyError(f"There already is a {template_type} "
f"template called {temp.signature.name}")
)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,9 @@ def test_dsl_conflicting_templates(dsl_conflicting_templates: typing.Dict[str, t
experiment.model.frontends.dsl.lightweight_validate(namespace)

assert e.value.errors() == [
{'loc': ['workflows', 1], 'msg': 'There already is a Workflow template called main'},
{'loc': ['components', 0], 'msg': 'There already is a Workflow template called main'},
{'loc': ['components', 2], 'msg': 'There already is a Component template called comp'}
{'loc': ['workflows', 1, "signature", "name"], 'msg': 'There already is a Workflow template called main'},
{'loc': ['components', 0, "signature", "name"], 'msg': 'There already is a Workflow template called main'},
{'loc': ['components', 2, "signature", "name"], 'msg': 'There already is a Component template called comp'}
]


Expand Down
6 changes: 3 additions & 3 deletions tests/test_package_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def test_load_dsl_with_bad_grammar(output_dir, dsl_conflicting_templates):
assert isinstance(error.underlyingError, experiment.model.errors.DSLInvalidError)

assert error.underlyingError.errors() == [
{'loc': ['workflows', 1], 'msg': 'There already is a Workflow template called main'},
{'loc': ['components', 0], 'msg': 'There already is a Workflow template called main'},
{'loc': ['components', 2], 'msg': 'There already is a Component template called comp'}
{'loc': ['workflows', 1, "signature", "name"], 'msg': 'There already is a Workflow template called main'},
{'loc': ['components', 0, "signature", "name"], 'msg': 'There already is a Workflow template called main'},
{'loc': ['components', 2, "signature", "name"], 'msg': 'There already is a Component template called comp'}
]


Expand Down

0 comments on commit 59a2d42

Please sign in to comment.