Skip to content

Commit

Permalink
Merge pull request cylc#5896 from oliver-sanders/id-traceback
Browse files Browse the repository at this point in the history
id: catch traceback in ID parsing
  • Loading branch information
wxtim authored Jan 2, 2024
2 parents 8527044 + acf3d91 commit 69988b0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cylc/flow/id_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ def _parse_cli(*ids: str) -> List[Tokens]:
>>> parse_back('//cycle')
Traceback (most recent call last):
InputError: Relative reference must follow an incomplete one.
E.G: workflow //cycle/task
>>> parse_back('workflow//cycle', '//cycle')
Traceback (most recent call last):
InputError: Relative reference must follow an incomplete one.
E.G: workflow //cycle/task
>>> parse_back('workflow///cycle/')
Traceback (most recent call last):
InputError: Invalid ID: workflow///cycle/
"""
# upgrade legacy ids if required
Expand All @@ -130,7 +132,11 @@ def _parse_cli(*ids: str) -> List[Tokens]:
if id_.endswith('/') and not id_.endswith('//'): # noqa: SIM106
# tolerate IDs that end in a single slash on the CLI
# (e.g. CLI auto completion)
tokens = Tokens(id_[:-1])
try:
# this ID is invalid with or without the trailing slash
tokens = Tokens(id_[:-1])
except ValueError:
raise InputError(f'Invalid ID: {id_}')
else:
raise InputError(f'Invalid ID: {id_}')
is_partial = tokens.get('workflow') and not tokens.get('cycle')
Expand Down

0 comments on commit 69988b0

Please sign in to comment.