fix(err): propagate exit code from underlying command (#846)#870
Open
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
Open
fix(err): propagate exit code from underlying command (#846)#870ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
rtk err <cmd>andrtk 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.Root Cause
run_err()andrun_test()insrc/cmds/rust/runner.rscomputedexit_codebut only passed it totee_and_hint()— they never calledstd::process::exit().Fix
Add
std::process::exit(exit_code)after output when the child exits non-zero, matching the established pattern ingit.rs,gt_cmd.rs, and all other command modules.Tests
Two
#[ignore]subprocess regression tests added:test_run_err_propagates_nonzero_exit_code—rtk err false→ exits 1test_run_err_zero_exit_on_success—rtk err true→ exits 0Fixes #846
🤖 Generated with Claude Code