Fix: cap aggregated exec output consistently#9759
Conversation
|
Note: 6 "Local Bazel build" checks are failing. The logs show BuildBuddy cache auth errors (UNAUTHENTICATED: missing API key), which is typical for forked PRs; not a code failure on this change. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
| let remaining = max_bytes.saturating_sub(want_stdout + stderr_take); | ||
| let stdout_take = want_stdout + remaining.min(stdout.text.len().saturating_sub(want_stdout)); | ||
|
|
||
| aggregated.extend_from_slice(&stdout.text[..stdout_take]); |
There was a problem hiding this comment.
Just FYI: ok for this because in bytes but using [] accessor in Rust in generally dangerous as it can panic. For example if you have a string containing multi-bytes characters, this accessor can split a char between its bytes and it will panic the runtime
WHAT?
WHY?
HOW?
aggregate_outputto compute stdout/stderr shares, then reassign unused capacity to the other stream.BEFORE
AFTER
TESTS
just fmtjust fix -p codex-corecargo test -p codex-core aggregate_output_cargo test -p codex-corecargo test --all-featuresFIXES
Fixes #9758