feat: add --traceback flag for full CLI stack traces#937
Conversation
CLI errors print a concise panel which is great for end users but makes debugging painful when a pipe fails deep in the runtime. Adds a global --traceback flag (intercepted in PipelexCLI.make_context, same pattern as --no-logo) that prints a Rich Traceback before the friendly error panel. All handle_* functions in error_handlers.py now call print_traceback_if_requested() at the top. Also wired into the PipelexError catch in run/_run_core.py so that generic pipeline failures also respect the flag. Tests: 10 new unit tests covering the helper, the flag interception, and the integration with error handlers.
Greptile SummaryThis PR adds an opt-in traceback flag for the Pipelex CLI. The main changes are:
Confidence Score: 3/5This is close, but the main run failure path should be fixed before merging.
Important Files Changed
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dbbd0f7fdb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…#937) The new traceback test module imported MagicMock from unittest.mock and packed several Test* classes into one file. Both violate AGENTS.md ("never use unittest.mock; use pytest-mock", "never put more than one TestClass into a test module"). Switch to pytest-mock fixtures and split the module into single-class files, one per area: - test_is_traceback_requested.py - test_print_traceback_if_requested.py - test_traceback_flag_error_handlers.py - test_make_context.py Test coverage and behaviour are unchanged. Per Codex review on PR Pipelex#937.
|
Thanks @Ylsssq926 for the contribution. One blocker before merge: the Fix: add could you also merge the dev branch inside your branch? |
thomashebrard pointed out in Pipelex#937 that the original patch only added print_traceback_if_requested at the outer except sites in execute_run. The inner async _execute_run already converts PipelineExecutionError / PipelexError / FileNotFoundError / PipelexInterpreterError / MthdsDecodeError / json.JSONDecodeError / JsonTypeError into typer.Exit locally, and the outer `except typer.Exit: raise` short-circuits before the new PipelexError branch can run. So `pipelex --traceback run` was still silent for the actual pipeline-failure scenario the issue describes. Add print_traceback_if_requested at the top of all seven inner except blocks in _execute_run so the flag fires before typer.Exit propagates, keeping the behaviour uniform across run command failure modes. Refs: Pipelex#937
|
You're right, the inner catches in
|
|
Great! Also one last thing: the new |
The test file had 6 pyright errors that only surfaced in CI (local validation only checked pipelex/cli/, not tests/). Fixed by: - Adding Coroutine[Any, Any, Any] and Any return type to _run_async - Adding pyright: ignore[reportPrivateUsage] on the _execute_run import - Moving Coroutine import into TYPE_CHECKING block per ruff TC003 Refs: Pipelex#937
Replace unittest.mock imports (MagicMock, patch) with pytest-mock MockerFixture to match the other four traceback test files, as requested by thomashebrard in Pipelex#937. Refs: Pipelex#937
|
Both fixed:
|
|
Hi @Ylsssq926 thanks a lot for your contribution. We need a moment to check it more thoroughly as it interacts with a bunch of other changes we are working on regarding error handling. |
|
Hello @Ylsssq926, Thanks again for this — really clean work. 🙏 The design is exactly right: intercepting We test-merged your branch into our current
The one conflict —
|
…flag-437 # Conflicts: # pipelex/cli/commands/run/_run_core.py
|
Thanks for the detailed review and for test-merging it! 🙏 Done — merged except PipelexInterpreterError as exc:
print_traceback_if_requested(get_console())
typer.secho(f"Failed to parse bundle '{bundle_path}': {exc}", fg=typer.colors.RED, err=True)
raise typer.Exit(1) from excThe Also added a Should be ready to merge now — thanks again! |
Closes #437
(Re-opening from #936 with the correct `feature/` branch name targeting `dev` per the project's branch policy. Same code.)
What
Adds a global `--traceback` flag to the `pipelex` CLI that prints a Rich-formatted stack trace before the friendly error panel, for any of the structured `handle_*` errors and the `PipelexError` branch in `run` execution.
Usage:
Why
Issue #437: when a pipeline fails, the friendly panel hides the actual Python stack and forces users to re-run with extra debug glue. An opt-in flag keeps the default output clean while giving an easy escape hatch.
How
Scope decisions (open to feedback)
Tests
10 new tests in `tests/unit/pipelex/cli/test_traceback_flag.py`:
Verification
Note
@airestful expressed interest 6 months ago but hasn't been assigned. Happy to defer if they'd like to pick it up.
Summary by cubic
Adds a global
--tracebackflag to thepipelexCLI that prints a Rich-formatted stack trace before the friendly error panel, making failures easier to debug. Addresses #437 without changing default output.New Features
--tracebackflag works anywhere in the command (intercepted inPipelexCLI.make_context; stored inctx.obj["traceback"]).print_traceback_if_requested(), so stacks show before panels across allhandle_*errors and allrunfailure paths, including inner_execute_runexceptions (file not found, interpreter, JSON decode/type,PipelineExecutionError,PipelexError).Bug Fixes
--tracebackinto_execute_runinner except blocks sopipelex runprints stacks before exiting.pytest-mock, and added type annotations to satisfy pyright.Written for commit defcdb1. Summary will update on new commits.