fix(changelog): Fetch PRs by merge date instead of update date - #18911
fix(changelog): Fetch PRs by merge date instead of update date#18911sfanahata wants to merge 1 commit into
Conversation
The changelog script was using `sort:updated-desc` in the GitHub Search query, which fetches PRs by their last update time rather than merge time. This caused old PRs (some from 2024!) to appear in the changelog if they were recently touched by bot comments, label changes, or cross-references. Fix: - Replace `sort:updated-desc` (an in-query qualifier that isn't even a valid Search Issues API sort option) with proper API parameters: `sort=created&order=desc` - Add `merged:>=YYYY-MM-DD` date filter (30-day window) to the search query to ensure only recently merged PRs are fetched - The script's existing post-fetch sort by `merged_at` then correctly orders the results This also resolves the redirect chain warnings in PR #18898, which were caused by an ancient PR (#15745, merged Dec 2025) appearing in the changelog because it was recently "updated".
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
||
| console.log('Fetching merged PRs...'); | ||
| const searchQuery = `repo:${REPO_OWNER}/${REPO_NAME} is:pr is:merged merged:>=${mergedSince}`; | ||
| const url = `https://api.github.com/search/issues?q=${encodeURIComponent(searchQuery)}&sort=created&order=desc&per_page=${PR_LIMIT}`; |
There was a problem hiding this comment.
Bug: The script fetches PRs sorted by creation date but then sorts by merge date. With a fixed limit of 50 PRs, recently merged but older PRs may be missed.
Severity: MEDIUM
Suggested Fix
Since the GitHub Search API does not support sorting by merge date, the script should be updated to use pagination. It should fetch all pull requests merged within the specified date range, page by page, and then perform the client-side sort by merged_at on the complete, unfiltered dataset to ensure no entries are missed.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: scripts/update-docs-changelog.mjs#L190
Potential issue: The script fetches the 50 most recently created pull requests from the
GitHub API using `sort=created`. However, it later sorts these results by their merge
date (`merged_at`) to generate the changelog. This mismatch can lead to incomplete
changelogs. If a pull request was created some time ago but only merged recently, it may
not be included in the initial fetch of 50 recently created PRs, even if it is one of
the most recently merged. This causes it to be silently omitted from the final
changelog.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 39445cb. Configure here.
|
|
||
| console.log('Fetching merged PRs...'); | ||
| const searchQuery = `repo:${REPO_OWNER}/${REPO_NAME} is:pr is:merged merged:>=${mergedSince}`; | ||
| const url = `https://api.github.com/search/issues?q=${encodeURIComponent(searchQuery)}&sort=created&order=desc&per_page=${PR_LIMIT}`; |
There was a problem hiding this comment.
Wrong API sort misses merges
Medium Severity
The search request sorts by created while only the first PR_LIMIT hits are kept. Among PRs matching the 30-day merged filter, that prefers newly opened PRs and can omit long-lived ones that just merged. The later merged_at sort never sees those dropped items, so the changelog can miss recent merges in a busy window.
Reviewed by Cursor Bugbot for commit 39445cb. Configure here.


Problem
PR #18898 (the first successful automated changelog PR) contains entries dating back to October 2024 and December 2025 instead of recent changes. This also triggers redirect chain warnings because those ancient PRs reference URLs that have since been moved.
Root Cause
The changelog script (
scripts/update-docs-changelog.mjs) usessort:updated-descin the GitHub Search API query. This fetches PRs sorted by their last update time, not their merge time. Old PRs that were recently touched by bot comments, label changes, or cross-references get pulled in instead of truly recent merged PRs.The Sentry Bot correctly identified this issue, though its suggested fix of
sort:merged-descdoesn't work -- the GitHub Search Issues API only supportscomments,reactions,created,updated, andinteractionsas sort values.Fix
sort:updated-descin-query qualifiermerged:>=YYYY-MM-DDdate filter (30-day rolling window) to limit results to recently merged PRssort=created&order=descThe script's existing post-fetch sort by
merged_atthen correctly orders the entries.Verification
Tested locally -- before vs. after:
Before: Entries from Oct 2024, Dec 2025, Jan 2025, Mar 2025, Apr 2025, etc.
After: All entries from July 28-31, 2026 (the last few days)
The 5 redirect chain warnings from #18898 are also eliminated since the ancient PR #15745 (Dec 2025) no longer appears.
Closes the content issue in #18898.