Repository navigation
fix(run): propagate signal exit code instead of unwrap_or(1) - #2681
Merged
Merged
Conversation
`Commands::Run` used `status.code().unwrap_or(1)` which silently maps signal kills (SIGTERM, SIGKILL, OOM) to exit code 1 instead of the POSIX-conventional 128+signal. Use the existing `exit_code_from_status()` helper already used by Commands::Proxy. Fixes rtk-ai#2680
Contributor
|
hey @guyoron1 thanks for the contribution, lgtm for better transparency on exit code propagation |
aeppling
approved these changes
Jun 28, 2026
sBucka
added a commit
to sBucka/rtk
that referenced
this pull request
Jul 3, 2026
Two gaps found on re-review against the same bug classes rtk has already fixed elsewhere: - Exit code was read via .code().unwrap_or(1), which silently reports 1 for a signal-killed curl (e.g. a timeout SIGTERM) instead of the conventional 128+signal. This is the exact bug fixed for `rtk run` in rtk-ai#2681; switched to the existing exit_code_from_output() helper. (curl_cmd still has the old pattern — left untouched, out of scope for this PR.) - The Markdown conversion was emitted directly, bypassing the never-worse guard (core::guard::never_worse / runner::emit_guarded) that curl_cmd already goes through. Without it, pathological/ adversarial HTML that happens to convert to something larger than the raw response would silently cost more tokens than plain curl — the same regression class rtk-ai#2551/rtk-ai#2554 generalized the guard to prevent. Now both the HTML and passthrough paths converge through emit_guarded before tracking, matching curl_cmd's structure. No behavior change for the common case (real pages still convert and shrink as before); this only changes the signal-exit-code edge case and adds a safety net for the pathological-HTML edge case. Re-verified against example.com, api.github.com/zen, and jsonplaceholder — HTML still converts, JSON/plain-text still passes through untouched.
6 tasks done
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.
Summary
status.code().unwrap_or(1)withexit_code_from_status(&status, "run")inCommands::Run(main.rs:2334)128+signalexit codes instead of silently mapping to1Commands::Proxyat line 2515Fixes #2680
Test plan
cargo fmt --all— no formatting changescargo clippy --all-targets— no warningscargo test --all— all tests passrtk run "sleep 99" &; kill -TERM $!should exit 143 (not 1)