Skip to content

Commit 69988b0

Browse files
authored
Merge pull request #5896 from oliver-sanders/id-traceback
id: catch traceback in ID parsing
2 parents 8527044 + acf3d91 commit 69988b0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cylc/flow/id_cli.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ def _parse_cli(*ids: str) -> List[Tokens]:
109109
>>> parse_back('//cycle')
110110
Traceback (most recent call last):
111111
InputError: Relative reference must follow an incomplete one.
112-
E.G: workflow //cycle/task
113112
114113
>>> parse_back('workflow//cycle', '//cycle')
115114
Traceback (most recent call last):
116115
InputError: Relative reference must follow an incomplete one.
117-
E.G: workflow //cycle/task
116+
117+
>>> parse_back('workflow///cycle/')
118+
Traceback (most recent call last):
119+
InputError: Invalid ID: workflow///cycle/
118120
119121
"""
120122
# upgrade legacy ids if required
@@ -130,7 +132,11 @@ def _parse_cli(*ids: str) -> List[Tokens]:
130132
if id_.endswith('/') and not id_.endswith('//'): # noqa: SIM106
131133
# tolerate IDs that end in a single slash on the CLI
132134
# (e.g. CLI auto completion)
133-
tokens = Tokens(id_[:-1])
135+
try:
136+
# this ID is invalid with or without the trailing slash
137+
tokens = Tokens(id_[:-1])
138+
except ValueError:
139+
raise InputError(f'Invalid ID: {id_}')
134140
else:
135141
raise InputError(f'Invalid ID: {id_}')
136142
is_partial = tokens.get('workflow') and not tokens.get('cycle')

0 commit comments

Comments
 (0)