test: formalize --json stdout/stderr discipline#1246
Merged
mergify[bot] merged 2 commits intomainfrom Apr 21, 2026
Merged
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced Apr 20, 2026
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 ⛓️ Depends-On RequirementsWonderful, this rule succeeded.Requirement based on the presence of
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 👀 Review RequirementsWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 ReviewsWonderful, this rule succeeded.
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
9de1f4d to
87a9f1b
Compare
93d528c to
a2e8e33
Compare
Member
Author
Revision history
|
a2e8e33 to
e03dc48
Compare
8fe4032 to
3675a78
Compare
e03dc48 to
af8e7cf
Compare
Pins the JSON output shape of `mergify stack list --json` so any drift is caught in CI. The Rust port will reuse this model as its output schema, and downstream scripts that parse this output get a stable contract. - New `mergify_cli/stack/list_schema.py` with Pydantic BaseModels mirroring StackListOutput.to_dict(). extra="forbid" rejects any new/renamed/removed fields or wrong types. - test_stack_list_json_output now validates parsed output against StackListJsonOutput. Failing here means either the code drifted (needs revert) or the shape changed intentionally (update both the dataclass and the schema in one commit, treat as a breaking change for consumers). `freeze list`, `queue status`, `queue show` are deliberately NOT locked: their JSON output is a passthrough of the Mergify API response, so the schema is the API's contract, not this CLI's. Added inline comments documenting that invariant so the Rust port preserves the passthrough behavior without introducing transformations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: I72306d8596c6ca7c4f2f562fc1298244417a57b3
Introduces a named test helper, ``assert_stdout_is_single_json_document``, and wires it into the four ``--json`` tests (``stack list``, ``queue status``, ``queue show``, ``freeze list``). The helper asserts that stdout under ``--json`` mode contains exactly one JSON document — no banners, no progress lines, no trailing text. Functionally identical to ``json.loads(stdout)`` (which already rejects trailing non-whitespace), but the helper gives future readers a clearly-named invariant to grep for and produces an explanatory failure message instead of a raw ``JSONDecodeError``. Nothing to fix in production code: a sweep of ``console.print``, ``click.echo``, and ``print()`` call sites found no leaks into the ``--json`` code paths. Recent fixes on main (e.g. 7adb94b) already cleaned up known cases. This PR exists to keep the invariant visible so future changes don't quietly regress it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: I5a37d5c1b0373eb00a0b61e90bdadf482e8693dd
af8e7cf to
8af3b7c
Compare
3675a78 to
b29bcfa
Compare
sileht
approved these changes
Apr 21, 2026
Base automatically changed from
devs/jd/worktree-rust-port/schema-lock-stack-list-json-output--72306d85
to
main
April 21, 2026 07:43
JulianMaurin
approved these changes
Apr 21, 2026
Contributor
Merge Queue Status
This pull request spent 7 minutes 7 seconds in the queue, including 5 minutes 4 seconds running CI. Required conditions to merge
|
36 tasks
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.
Introduces a named test helper,
assert_stdout_is_single_json_document,and wires it into the four
--jsontests (stack list,queue status,queue show,freeze list).The helper asserts that stdout under
--jsonmode containsexactly one JSON document — no banners, no progress lines, no
trailing text. Functionally identical to
json.loads(stdout)(which already rejects trailing non-whitespace), but the helper
gives future readers a clearly-named invariant to grep for and
produces an explanatory failure message instead of a raw
JSONDecodeError.Nothing to fix in production code: a sweep of
console.print,click.echo, andprint()call sites found no leaks into the--jsoncode paths. Recent fixes on main (e.g. 7adb94b) alreadycleaned up known cases. This PR exists to keep the invariant
visible so future changes don't quietly regress it.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Depends-On: #1243