From 2d2e97aaec2e81a903197dd4a268a09c83bec1b2 Mon Sep 17 00:00:00 2001 From: Shannon Anahata Date: Fri, 31 Jul 2026 14:21:12 -0700 Subject: [PATCH 1/2] fix(changelog): Use List PRs API instead of Search to fetch recent merges The changelog script was using the GitHub Search API with `sort:updated-desc`, 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 or label changes. Switch to the List Pull Requests API (`/repos/{owner}/{repo}/pulls`) with `state=closed&base=master&sort=updated&direction=desc`. This returns the 100 most recently updated closed PRs, which we filter to only merged ones client-side. The existing post-fetch sort by `merged_at` then correctly orders the entries. This approach: - Returns the most recent 100 closed PRs in a single API call - Avoids the Search API's sort limitations entirely - Doesn't need a date window or pagination - Resolves the redirect chain warnings in PR #18898 (caused by ancient PRs appearing due to the sort bug) --- scripts/update-docs-changelog.mjs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/update-docs-changelog.mjs b/scripts/update-docs-changelog.mjs index 3d5c77802a27c8..de5194082af628 100644 --- a/scripts/update-docs-changelog.mjs +++ b/scripts/update-docs-changelog.mjs @@ -159,8 +159,10 @@ const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const REPO_OWNER = 'getsentry'; const REPO_NAME = 'sentry-docs'; -// Number of PRs to fetch -const PR_LIMIT = 50; +// Number of recently closed PRs to fetch (the List PRs API returns them +// sorted by most recently updated, so this grabs the latest batch and we +// filter to only merged ones client-side). +const PR_LIMIT = 100; // PRs to exclude (bot PRs, CI updates, etc.) const EXCLUDED_AUTHORS = ['github-actions[bot]', 'dependabot[bot]', 'getsentry-bot']; @@ -181,11 +183,13 @@ async function fetchMergedPRs() { headers['Authorization'] = `Bearer ${GITHUB_TOKEN}`; } - // Fetch recently merged PRs - const searchQuery = `repo:${REPO_OWNER}/${REPO_NAME} is:pr is:merged sort:updated-desc`; - const url = `https://api.github.com/search/issues?q=${encodeURIComponent(searchQuery)}&per_page=${PR_LIMIT}`; + // Use the List Pull Requests API instead of Search. It returns PRs sorted + // by most recently updated and lets us filter to state=closed + base=master. + // We then keep only the ones that were actually merged (merged_at != null). + // This avoids the Search API's sort limitations that caused stale entries. + const url = `https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/pulls?state=closed&base=master&sort=updated&direction=desc&per_page=${PR_LIMIT}`; - console.log('Fetching merged PRs...'); + console.log('Fetching recently closed PRs...'); const response = await fetch(url, {headers}); @@ -193,10 +197,12 @@ async function fetchMergedPRs() { throw new Error(`GitHub API error: ${response.status} ${response.statusText}`); } - const data = await response.json(); - console.log(`Found ${data.items.length} merged PRs`); + const allPRs = await response.json(); + const mergedPRs = allPRs.filter(pr => pr.merged_at !== null); - return data.items; + console.log(`Fetched ${allPRs.length} closed PRs, ${mergedPRs.length} were merged`); + + return mergedPRs; } async function fetchPRDetails(prNumber) { From e0444f37e7ef604831cabb06ccd8fadcfcd1ca80 Mon Sep 17 00:00:00 2001 From: Shannon Anahata Date: Wed, 12 Aug 2026 10:22:37 -0700 Subject: [PATCH 2/2] chore(changelog): Run weekly instead of daily --- .github/workflows/update-docs-changelog.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-docs-changelog.yml b/.github/workflows/update-docs-changelog.yml index 659d2ab5687204..53fdd4659d5ed0 100644 --- a/.github/workflows/update-docs-changelog.yml +++ b/.github/workflows/update-docs-changelog.yml @@ -1,9 +1,9 @@ name: Update Docs Changelog on: - # Run daily at midnight UTC + # Run weekly on Monday at midnight UTC schedule: - - cron: '0 0 * * *' + - cron: '0 0 * * 1' # Allow manual trigger workflow_dispatch: