Repository navigation
[SEL-391] Cap JSON error objects at 512 bytes under an explicit --timeout - #149
Merged
Merged
Conversation
…it (SEL-391)
With an explicit --timeout a hard exit fires if the command is stuck. If
stdout is stalled and an error object is larger than the pipe's atomic
write size, the kernel takes part of it, the write blocks, and the hard
exit leaves an unterminated line on stdout. Any error object can be that
large, not only timeout errors: a network_error with a long hostname was
cut 5 of 5.
When --timeout is given explicitly, an error object on stdout is now at
most 512 bytes including its newline, measured after JSON encoding, and
written in one Write. v, error and message are kept, message shortened
on a UTF-8 boundary if needed. Other fields are kept only while the
object still fits, never partially. sel doctor's object carries
failed_check (the first failing check's name) in place of the doctor
field, and the full document goes to stderr as one {"v":1,"doctor":{...}}
line after the stdout object.
Choices the decision did not cover: a server-supplied error code that
alone cannot fit is shortened to fit, with an empty message; extra
fields are tried in key order and a field that does not fit is skipped,
later smaller ones are still kept. Pending-approval documents are not
error objects and are unchanged.
Without an explicit --timeout, and with --watch (no hard exit), output
is unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
They need no pipe stall, only a child process and a server, so they use runBinaryIn instead of the Linux-only runCapped. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
This was referenced Nov 22, 2026
natevick
marked this pull request as ready for review
November 22, 2026 20:51
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.
SEL-391. With an explicit
--timeout, a JSON error object larger than the pipe's atomic write could be cut by the hard exit when stdout is stalled. Now, once the command has started, each JSON error object on stdout is at most 512 bytes including its newline, in oneWrite.Do not merge without #155, which keeps
approvaland other fields this PR drops under--timeout.Changes (explicit
--timeoutonly)format.BoundedErrorkeepsv,error,message, shortensmessageon a UTF-8 boundary, keeps other fields only while they fit.sel doctor: stdout carriesfailed_checkinstead ofdoctor; the full document goes to stderr as one{"v":1,"doctor":{...}}line after the stdout object.--timeout, error and run output match v0.4.0. The only change is four new lines insel doctor's help.One exit code change. When a pipe had room for only part of an oversized error, it was cut and exited 8. The smaller object now lands and exits with its real code (4 for
network_error, 5 for a 422). A completely full pipe still exits 8.Choices the decision did not cover
--watch, not measured.messagecan crowd outfailed_check. A field that does not fit is skipped.Needs a decision
--timeout, on v0.4.0 too. Doctor redacts. Fixing it changes output without--timeout, so untouched.Checks (
lanes/lane-3/evidence/sel391/,v041/second-opinion-2.md)network_errorand2>&1: red on8bb9d50b, green here, 20 of 20 in an independent rerun. Cap bypassed: red by assertion.8bb9d50b, 0 of 135 on head.go test -race, 21 of 21) pass on this head. The 57 clock, backstop, reader and hangup tests ran 20x under-raceon1edcf3e; on this head only the 3 new ones.Not run or not established
2>&1.BoundedError.🤖 Generated with Claude Code
https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp