refactor(stack): schema-lock stack list --json output#1243
Conversation
|
This pull request is part of a Mergify stack:
|
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 🤖 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
Revision history
|
There was a problem hiding this comment.
Pull request overview
Pins the JSON output contract of mergify stack list --json by introducing a dedicated Pydantic schema and validating CLI output against it in tests, while explicitly documenting that other JSON outputs remain API passthroughs (for the upcoming Rust port and downstream tooling).
Changes:
- Add
StackListJsonOutputPydantic models to lock thestack list --jsonoutput shape (extra="forbid"). - Update
test_stack_list_json_outputto validate emitted JSON against the pinned schema. - Document that
freeze list,queue status, andqueue showJSON outputs are intentional API passthroughs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
mergify_cli/tests/stack/test_list.py |
Validates stack list --json output against the pinned Pydantic model in CI. |
mergify_cli/stack/list_schema.py |
Introduces the Pydantic schema models used to lock the JSON output shape. |
mergify_cli/queue/cli.py |
Adds comments clarifying JSON output is a passthrough of the Mergify API response. |
mergify_cli/freeze/cli.py |
Adds comments clarifying JSON output is a passthrough of the Mergify API response. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
87a9f1b to
8fe4032
Compare
8fe4032 to
3675a78
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
3675a78 to
b29bcfa
Compare
Merge Queue Status
This pull request spent 5 minutes 41 seconds in the queue, including 5 minutes 12 seconds running CI. Required conditions to merge
|
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> Depends-On: #1243
Pins the JSON output shape of
mergify stack list --jsonso anydrift 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.
mergify_cli/stack/list_schema.pywith Pydantic BaseModelsmirroring StackListOutput.to_dict(). extra="forbid" rejects any
new/renamed/removed fields or wrong types.
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 showare deliberately NOTlocked: 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