feat(ci): read merge-queue metadata as a generic value, tolerating key renames#1723
Conversation
…y renames `queue_metadata::parse_yaml_block` modeled the MQ draft-PR-body payload with a rigid serde struct whose `draft_pr_number` was required. The engine (MRGFY-8075) renamed that key to `batch_pr_number` and dual-emits both for one release window before dropping the old spelling. A missing required field fails the *whole document*, and the caller's `.ok()` swallows that into `None`, so once the alias is gone every batch body with a non-empty `previous_failed_batches` would silently cost `git-refs` its `checking_base_sha` and diff against the wrong base, with no error surfaced anywhere. That struct has been dead code since #1600: its only reader, `git_refs`, uses just `checking_base_sha`; every other field is parsed and discarded. So rather than a `#[serde(alias)]` band-aid on one key, parse the payload into a generic `serde_json::Value` — exactly how the git-note twin (`git::read_note`) already reads the identical payload — and pull `checking_base_sha` out with the existing shared helper. The CLI is now immune to any engine key rename in this block, with no schema left to drift and no call-site churn. While here: warn instead of silently falling through to the PR base when MQ metadata is present but carries no `checking_base_sha`, so a future rename of that key can't degrade the base silently either; and share the YAML-mapping parse between the note and PR-body readers so they can't diverge in what they accept. Fixes MRGFY-8104 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Change-Id: I6732b7057db0c98a7bb275d95fbd6470e39bad8b
Merge Protections🟢 All 6 merge protections satisfied — ready to merge. Show 6 satisfied protections🟢 🤖 Continuous Integration
🟢 👀 Review Requirements
🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 Reviews
🟢 📕 PR description
🟢 🚦 Auto-queueWhen all merge protections are satisfied, this pull request will be queued automatically. |
There was a problem hiding this comment.
Pull request overview
This PR hardens mergify-ci’s merge-queue metadata extraction against engine-side YAML key renames by parsing the fenced PR-body block (and git-note payload) into a generic serde_json::Value, then extracting only checking_base_sha via a shared helper. It also makes silent “wrong base” fallthroughs observable by emitting a warning when MQ metadata exists but lacks checking_base_sha.
Changes:
- Replace rigid
serdestructs for PR-body MQ metadata with a genericserde_json::Valueparse, mirroring the existing git-note reader approach. - Share a single YAML-mapping parser (
parse_yaml_mapping) between git-note and PR-body readers to keep accepted shapes in sync. - Warn (human-mode only) when MQ metadata is present but missing
checking_base_sha, and add regression tests for the reported failure mode.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/mergify-ci/src/queue_metadata.rs | Switch PR-body fenced YAML parsing to a generic value and expand tests to cover key renames/unknown keys/non-mapping payloads. |
| crates/mergify-ci/src/git.rs | Introduce shared parse_yaml_mapping used by both note and PR-body parsing paths, keeping behavior aligned. |
| crates/mergify-ci/src/git_refs.rs | Extract checking_base_sha from generic metadata, warn on missing key, and add tests for the reported regression and warning behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge Queue Status
This pull request spent 7 minutes 9 seconds in the queue, including 6 minutes 52 seconds running CI. Required conditions to merge
|
queue_metadata::parse_yaml_blockmodeled the MQ draft-PR-body payloadwith a rigid serde struct whose
draft_pr_numberwas required. Theengine (MRGFY-8075) renamed that key to
batch_pr_numberand dual-emitsboth for one release window before dropping the old spelling. A missing
required field fails the whole document, and the caller's
.ok()swallows that into
None, so once the alias is gone every batch bodywith a non-empty
previous_failed_batcheswould silently costgit-refsits
checking_base_shaand diff against the wrong base, with no errorsurfaced anywhere.
That struct has been dead code since #1600: its only reader,
git_refs,uses just
checking_base_sha; every other field is parsed and discarded.So rather than a
#[serde(alias)]band-aid on one key, parse the payloadinto a generic
serde_json::Value— exactly how the git-note twin(
git::read_note) already reads the identical payload — and pullchecking_base_shaout with the existing shared helper. The CLI is nowimmune to any engine key rename in this block, with no schema left to
drift and no call-site churn.
While here: warn instead of silently falling through to the PR base when
MQ metadata is present but carries no
checking_base_sha, so a futurerename of that key can't degrade the base silently either; and share the
YAML-mapping parse between the note and PR-body readers so they can't
diverge in what they accept.
Fixes MRGFY-8104
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com