Skip to content
Open
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
10 changes: 10 additions & 0 deletions metaflow/client/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ def __init__(
if pathspec and _object is None:
ids = pathspec.split("/")

# Reject blank components (empty string or whitespace-only), e.g. "Flow//Step"
# or "Flow/ /Step". Check before the length tests so the error is specific.
blank = [i for i, c in enumerate(ids) if not c.strip()]
if blank:
raise MetaflowInvalidPathspec(
"Pathspec '%s' has an empty or blank component at position(s) %s. "
"Each '/' must separate non-empty path parts."
% (pathspec, ", ".join(str(p) for p in blank))
)
Comment on lines +328 to +332

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The positions are reported as 0-based indices, but end-users mentally count path components from 1 (e.g., "Flow/ /Step" — component 2 is blank, not component 1). Using 1-based positions in the error message would be more intuitive here.

Suggested change
raise MetaflowInvalidPathspec(
"Pathspec '%s' has an empty or blank component at position(s) %s. "
"Each '/' must separate non-empty path parts."
% (pathspec, ", ".join(str(p) for p in blank))
)
raise MetaflowInvalidPathspec(
"Pathspec '%s' has an empty or blank component at position(s) %s. "
"Each '/' must separate non-empty path parts."
% (pathspec, ", ".join(str(p + 1) for p in blank))
)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


if self._NAME == "flow" and len(ids) != 1:
raise MetaflowInvalidPathspec("Expects Flow('FlowName')")
elif self._NAME == "run" and len(ids) != 2:
Expand Down
Loading