Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

id: catch traceback in ID parsing #5896

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading