Skip to content

Commit 0e20ca6

Browse files
authored
Use SourceLine in _resolve_idmap to include line number in error (#562)
1 parent 749980e commit 0e20ca6

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

schema_salad/ref_resolver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,11 @@ def _resolve_idmap(
592592
)
593593
v.lc.filename = document.lc.filename
594594
else:
595+
sl = SourceLine(document, idmapField, str)
595596
raise ValidationException(
596597
"mapSubject '{}' value '{}' is not a dict "
597-
"and does not have a mapPredicate.".format(k, v)
598+
"and does not have a mapPredicate.".format(k, v),
599+
sl,
598600
)
599601
else:
600602
v = val
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
cwlVersion: v1.0
4+
class: Workflow
5+
label: geoweaver workflow
6+
7+
inputs:
8+
code_folder:
9+
type: File
10+
11+
outputs: []
12+
13+
steps:
14+
run: HelloWorld.cwl
15+
in:
16+
folder: code_folder
17+
out: []

schema_salad/tests/test_ref_resolver.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import shutil
66
import sys
77
import tempfile
8-
from typing import Union
8+
from typing import Union, Any
99

1010
import pytest
1111
from _pytest.fixtures import FixtureRequest
1212
from requests import Session
1313
from ruamel.yaml.comments import CommentedMap, CommentedSeq
1414

15+
import schema_salad.main
1516
from schema_salad.exceptions import ValidationException
1617
from schema_salad.fetcher import DefaultFetcher
1718
from schema_salad.ref_resolver import Loader, file_uri
@@ -259,3 +260,17 @@ def test_check_exists_follows_redirects() -> None:
259260
# for previous bug where allow_redirects wasn't set and as a
260261
# result it would return True even though the result was 3xx.
261262
assert not fetcher.check_exists("http://commonwl.org/does/not/exist")
263+
264+
265+
def test_resolve_missing_step_id(caplog: Any) -> None:
266+
"""From issue #cwltool/issues/1635. A Workflow with a Step without
267+
the name attribute must raise a ValidationException that contains
268+
the SourceLine data."""
269+
schema_path = get_data("tests/test_schema/CommonWorkflowLanguage.yml")
270+
document_path = get_data("tests/missing_step_name.cwl")
271+
if not schema_path or not document_path:
272+
pytest.fail("Could not get data for the test")
273+
assert 1 == schema_salad.main.main(
274+
argsl=["--print-rdf", schema_path, document_path]
275+
)
276+
assert "missing_step_name.cwl:13:1" in "\n".join(caplog.messages)

0 commit comments

Comments
 (0)