Repository navigation
fix(cli): refuse an unknown ingest --step with exit code 2 - #783
kstonekuan merged 2 commits into
Conversation
Running `hflow ingest --step NAME` with no runtime addressed crashed with a traceback and exit code 1 when NAME was not a registered step, or when its stage was disabled by the chosen --profile. Both are bad input, which docs/FORMAT.md assigns exit code 2 and a `command: message` line. The in-process executor now parses the step selection before it announces or starts any processing and reports a refusal as `ingest: <reason>`. Only that parse is guarded: an error raised while episodes are being processed still surfaces as before.
|
👋 Hi @vincentvega011 — thank you so much for your first contribution to HFlow! A maintainer will review your pull request as soon as possible. In the meantime:
💡 Tip: one open pull request per contributor at a time. Before starting an issue, check its sidebar for an assignee or a linked pull request. Either one means somebody is already on it; everything else is fair game. We are excited to have you here and appreciate your help making the project better! 🙌 |
[Low impact] The PR appears safe to merge.
|
kstonekuan
left a comment
There was a problem hiding this comment.
Behaviour's right, and both new tests fail without the fix.
_ingest_in_process picks enabled_stage_names[0] to call a per-stage resolver and throws the answer away, and it takes five lines of comment to explain why. Can the selection be validated without naming a stage?
Also, how does a TypeError reach that except from the CLI?
Add a public, stage-free resolve_step_selection in stage_execution and route its callers through it. The in-process ingest path now validates the selection with it before the banner instead of borrowing the per-stage resolver, and catches only ValueError: Typer only passes list[str] | None, so the TypeError guards cannot fire from the CLI.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
Thanks! Yes: It can't: Typer only ever passes If you'd rather the selection be parsed once, I can have |
kstonekuan
left a comment
There was a problem hiding this comment.
LGTM, merging. Both new tests fail without the fix, 2638 passed on a merge with main. Thanks!
Summary
hflow ingest --step NAMEwith no runtime addressed now refuses a stepselection it cannot honour with a one-line
ingest: ...message and exitcode 2, before any episode is read. Previously it printed a Python traceback
and exited 1.
Two cases are covered:
ingest: unknown step names ['nope']; registered steps: [...]--profile relabel --step <a check>:ingest: selected steps belong to stages that are not enabled: [...]; enabled stages: ['labels']Why
--stepis a documented flag and a mistyped name is the most likely mistakewith it.
docs/FORMAT.mddefines exit code 2 as bad input and 1 as "ran, andfound something to report", so a script could not tell a typo from failed
episodes, and the reason was buried under a traceback.
_ingest_in_processonly caughtRuntimeError(the mass-failure gates), sothe
ValueErrorfrom step selection escaped. The fix parses the selection upfront through the existing
resolve_step_names_for_stageand guards only thatcall. The handler around
run_stages_directlyis unchanged, so aValueErrorraised while processing still surfaces as a real failure.
Scope is the in-process executor only. The Airflow path is untouched: from
reading
AirflowClient.ingest, step names are forwarded in the run confwithout being checked against the registered steps, so an unknown name there
is only refused inside the DAG tasks after the run is triggered. I have not
exercised that against a running runtime, and it seemed better handled
separately.
No transform behaviour or step version changes; no stored data is affected.
Validation
On macOS (Python 3.14, system ffmpeg 9.0.2):
uv run pytest -q tests/test_ingest_in_process.py -k step_selectionValueErrorfrom step selection)uv run ruff check --fix- All checks passeduv run ruff format- 321 files left unchangeduv run ty check- All checks passeduv run pytest -q -n 4- 2604 passed, 49 skippedhflow ingest landing/ep1.mcap --step nope- one-line message, exit 2hflow ingest landing/ep1.mcap --profile relabel --step timestamps- one-line message, exit 2Not run: the lychee link check (not installed; the docs edit adds no links)
and the opt-in Docker runtime tests (the runtime path is unchanged).
Checklist
uv run ruff check --fix,uv run ruff format, anduv run ty check.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.