Repository navigation
docs: say stdout keeps a partial JSON result after a failure - #1116
Conversation
WhyThe page said that a failure after a streamed page still leaves one JSON document on stdout. That is false. A script that parses stdout after a failed streamed command can read a prefix that is not JSON. WhatThe new text says stdout keeps the bytes already written. Those bytes can stop inside an object that is not closed. The examples are HowThis matches the CLI on current Auto-pagination writes one open object and flushes each page. The four auto-paginated JSON commands are:
A command that fails before any result byte still writes one pretty JSON failure on stdout. These history commands are reads. A read failure has Human mode still prints the ImpactA caller must not parse stdout after a non-zero streamed command. The failure document on stderr is one pretty JSON value and includes BlockingNone. Optional
Inline note on Optional. Tradeoff and liabilityCorrectness comes first. Each page is flushed so a long result does not stay resident. The cost is that a failed run can leave stdout that is not valid JSON. Closing the object on the failure path would hide a short read. The old sentence did that in the docs. This change removes a false operator contract. It adds no API, state, or storage rule. The code behavior is unchanged. The sentence has to stay true for the three JSON stream writers. The comments in
No other open pull request edits this sentence. #1115 still uses Earlier findingOptional finding 1 on #1078 at ValidationReviewed head GQT does not apply. GQT checks rows, counts, column types, and query errors. It does not see which stdio stream holds a failure, or a prefix that is not a document. This pull request does not change behavior. Temporary probe on main, then removed. Not pushed. One page from each JSON stream, with no
Passed. Each prefix starts with Existing tests on that same tree:
5 passed. The routing test checks both sides. With no result byte, the failure JSON is on stdout, stderr is empty, exit is 1, and
I did not run a live multi-page RecommendationMerge. The optional names can land here or in a follow-up. |
What
docs/user/operations/troubleshooting.mdsaid that when part of a JSON result already reached stdout, the failure goes to stderr "so stdout holds one document". That is not what a streamed command leaves behind.diff --jsonandchanges poll --jsonwrite one open object, and a later page error leaves that prefix on stdout. The sentence now says stdout keeps the bytes already written, which can end inside an unfinished object, and that the failure document is on stderr.Why
Optional finding 1 of the review of #1078 at
e3f98130, which merged before it could be addressed there. A script that reads stdout after a failed streamed command must not assume it parses.Verification
python3 scripts/check-docs.py: Documentation OK.typoson the changed file: clean. Documentation only; no behavior changes.