Skip to content

fix(err): propagate exit code from underlying command (#846)#870

Open
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/err-exit-code
Open

fix(err): propagate exit code from underlying command (#846)#870
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/err-exit-code

Conversation

@ousamabenyounes
Copy link
Copy Markdown
Contributor

Problem

rtk err <cmd> and rtk test <cmd> always returned exit code 0, even when the underlying command failed. This broke CI/CD pipelines that rely on non-zero exit codes for error detection.

rtk err false # Output: [FAIL] Command failed (exit code: Some(1)) # Exit: 0 ← should be 1

Root Cause

run_err() and run_test() in src/cmds/rust/runner.rs computed exit_code but only passed it to tee_and_hint() — they never called std::process::exit().

Fix

Add std::process::exit(exit_code) after output when the child exits non-zero, matching the established pattern in git.rs, gt_cmd.rs, and all other command modules.

Tests

Two #[ignore] subprocess regression tests added:

  • test_run_err_propagates_nonzero_exit_codertk err false → exits 1
  • test_run_err_zero_exit_on_successrtk err true → exits 0
cargo test cmds::rust::runner -- --include-ignored # 3 passed ✅ 

Fixes #846

🤖 Generated with Claude Code

rtk err and rtk test were returning exit 0 regardless of whether the child command succeeded or failed — breaking CI/CD pipelines that rely on exit codes for error detection. Fix: call std::process::exit(exit_code) after output when the child exits non-zero, matching the exit-code propagation pattern used in git.rs, gt_cmd.rs, and other command modules. Add two #[ignore] subprocess regression tests that verify: - rtk err false → exits 1 (not 0) - rtk err true → exits 0 Fixes rtk-ai#846 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants