fix(ci): reconcile stale release-please state before the action #33

Merged
Noel merged 1 commits from fix/release_please_tags into main 2026-10-31 19:09:30 +00:00
Owner

PR #22 kept autorelease: pending after its head branch was deleted. Gitea rewrites head.ref to refs/pull/22/head, so the action cannot tag it and every later run then aborts with 'There are untagged, merged release PRs outstanding' - no new release PR is ever opened.

Add a reconciliation step that marks a pending PR tagged when its tag already exists, and recreates the tag from the manifest at the merge commit when the branch is gone and the tag is missing.

PR #22 kept autorelease: pending after its head branch was deleted. Gitea rewrites head.ref to refs/pull/22/head, so the action cannot tag it and every later run then aborts with 'There are untagged, merged release PRs outstanding' - no new release PR is ever opened. Add a reconciliation step that marks a pending PR tagged when its tag already exists, and recreates the tag from the manifest at the merge commit when the branch is gone and the tag is missing.

Failed to update PR description

Failed to update PR description

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Unvalidated tag match

The first reconciliation path marks a pending PR as autorelease: tagged whenever any tag points at the merge commit (tagSha.get(mergeSha)), without checking that the tag is a release tag (e.g. v-prefixed) or that it matches the version in the manifest. If any non-release tag (from CI tooling, a manual annotation, etc.) happens to land on the merge commit, the PR is marked tagged and the actual release tag release-please would have created is never made — the release silently never exists while the pipeline looks healthy. Verifying the tag name matches v${versionAt(mergeSha)} (or at least a release-tag pattern) before swapping the label would close this.

const existingTag = tagSha.get(mergeSha)
const labels = (pull.labels ?? []).map(label => label.name)

if (existingTag) {
  console.log(`#${pull.number}: ${existingTag} already points at merge commit ${mergeSha} - marking as tagged`)
  const next = labels.filter(name => name !== PENDING)
  if (!next.includes(TAGGED)) next.push(TAGGED)
  await replaceLabels(pull.number, next)
  continue
}
Pagination race

listAll('/pulls?state=closed') pages through closed PRs with limit=50&page=N. Gitea's default sort for this endpoint is newest-first, so if new PRs are closed while the loop is paginating, items shift between pages and some closed PRs can be skipped or visited twice. For a pending PR that lands on a skipped page, the reconcile step silently does nothing that run. Sorting explicitly (e.g. by ascending number, if the API supports a sort parameter) or filtering by a recent-time window would make the enumeration stable. Severity is low given the step re-runs on every push, but it can delay recovery by a run.

const listAll = async (path) => {
  const items = []
  for (let page = 1; ; page++) {
    const separator = path.includes('?') ? '&' : '?'
    const batch = await api(`${path}${separator}limit=50&page=${page}`)
    items.push(...batch)
    if (batch.length < 50) return items
  }
}
## PR Reviewer Guide 🔍 <!-- pr-agent:review:full --> Here are some key observations to aid the review process: <table> <tr><td>⏱️&nbsp;<strong>Estimated effort to review</strong>: 3 🔵🔵🔵⚪⚪</td></tr> <tr><td>🧪&nbsp;<strong>No relevant tests</strong></td></tr> <tr><td>🔒&nbsp;<strong>No security concerns identified</strong></td></tr> <tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br> <details><summary><a href='https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/src/branch/fix/release_please_tags/scripts/reconcile-release-please.mjs#L129-L138'><strong>Unvalidated tag match</strong></a> The first reconciliation path marks a pending PR as `autorelease: tagged` whenever *any* tag points at the merge commit (`tagSha.get(mergeSha)`), without checking that the tag is a release tag (e.g. `v`-prefixed) or that it matches the version in the manifest. If any non-release tag (from CI tooling, a manual annotation, etc.) happens to land on the merge commit, the PR is marked tagged and the actual release tag release-please would have created is never made — the release silently never exists while the pipeline looks healthy. Verifying the tag name matches `v${versionAt(mergeSha)}` (or at least a release-tag pattern) before swapping the label would close this. </summary> ```txt const existingTag = tagSha.get(mergeSha) const labels = (pull.labels ?? []).map(label => label.name) if (existingTag) { console.log(`#${pull.number}: ${existingTag} already points at merge commit ${mergeSha} - marking as tagged`) const next = labels.filter(name => name !== PENDING) if (!next.includes(TAGGED)) next.push(TAGGED) await replaceLabels(pull.number, next) continue } ``` </details> <details><summary><a href='https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/src/branch/fix/release_please_tags/scripts/reconcile-release-please.mjs#L64-L72'><strong>Pagination race</strong></a> `listAll('/pulls?state=closed')` pages through closed PRs with `limit=50&page=N`. Gitea's default sort for this endpoint is newest-first, so if new PRs are closed while the loop is paginating, items shift between pages and some closed PRs can be skipped or visited twice. For a pending PR that lands on a skipped page, the reconcile step silently does nothing that run. Sorting explicitly (e.g. by ascending number, if the API supports a sort parameter) or filtering by a recent-time window would make the enumeration stable. Severity is low given the step re-runs on every push, but it can delay recovery by a run. </summary> ```txt const listAll = async (path) => { const items = [] for (let page = 1; ; page++) { const separator = path.includes('?') ? '&' : '?' const batch = await api(`${path}${separator}limit=50&page=${page}`) items.push(...batch) if (batch.length < 50) return items } } ``` </details> </td></tr> </table>
Noel added 1 commit 2026-10-31 19:07:12 +00:00
fix(ci): validate the release tag and query pending PRs by label
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m8s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 8s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
7ffc6d73b6
Both PR-Agent findings were confirmed. A tag at the merge commit now counts only when it is exactly v<manifest version>; foreign CI or annotation tags are logged and ignored. Pending release PRs are fetched through the autorelease: pending label filter instead of paging every closed PR, so a concurrent close cannot shift a page and hide one.

Also fail loudly on a merged PR without merge_commit_sha or a manifest without a version, instead of producing vundefined.

Rebased on main after the separate audit fix (e0c69c1); the dependency overrides and lockfile changes from the earlier local commit were dropped. Verified on the rebased tree: lint, typecheck, build, the exact audit command, actionlint and a live dry run.
Noel force-pushed fix/release_please_tags from 258b03e458 to 7ffc6d73b6 2026-10-31 19:07:12 +00:00 Compare
Noel merged commit 06e1d24977 into main 2026-10-31 19:09:30 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: CV_Website/CV_Site_Nuxt#33