Skip to content

feat(ci): read merge-queue metadata as a generic value, tolerating key renames#1723

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/sileht/mrgfy-8104-cli-read-batch-pr-number/read-merge-queue-metadata-generic-value--6732b705
Jul 20, 2026
Merged

feat(ci): read merge-queue metadata as a generic value, tolerating key renames#1723
mergify[bot] merged 1 commit into
mainfrom
devs/sileht/mrgfy-8104-cli-read-batch-pr-number/read-merge-queue-metadata-generic-value--6732b705

Conversation

@sileht

@sileht sileht commented Jul 17, 2026

Copy link
Copy Markdown
Member

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

…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
Copilot AI review requested due to automatic review settings July 17, 2026 15:26
@mergify
mergify Bot deployed to Mergify Merge Protections July 17, 2026 15:26 Active
@sileht
sileht temporarily deployed to func-tests-live July 17, 2026 15:26 — with GitHub Actions Inactive
@mergify

mergify Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 6 merge protections satisfied — ready to merge.

Show 6 satisfied protections

🟢 🤖 Continuous Integration

  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|internal|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?!?:

🟢 🔎 Reviews

  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

  • body ~= (?ms:.{48,})

🟢 🚦 Auto-queue

When all merge protections are satisfied, this pull request will be queued automatically.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 serde structs for PR-body MQ metadata with a generic serde_json::Value parse, 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.

@mergify
mergify Bot requested a review from a team July 17, 2026 15:33
@sileht
sileht marked this pull request as ready for review July 17, 2026 17:05
@mergify
mergify Bot requested a review from a team July 18, 2026 05:42
@mergify

mergify Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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

@mergify mergify Bot added the queued label Jul 20, 2026
@mergify
mergify Bot merged commit bc0bbdf into main Jul 20, 2026
23 checks passed
@mergify
mergify Bot deleted the devs/sileht/mrgfy-8104-cli-read-batch-pr-number/read-merge-queue-metadata-generic-value--6732b705 branch July 20, 2026 07:52
@mergify mergify Bot removed the queued label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants