Skip to content

fix(ci): create workflow labels idempotently instead of searching first - #431

Merged
nickvigilante merged 2 commits into
mainfrom
vigilante/reconcile-label-race
Dec 4, 2026
Merged

nickvigilante merged 2 commits into
mainfrom
vigilante/reconcile-label-race

Conversation

@nickvigilante

@nickvigilante nickvigilante commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Merge order

Independent of every other open PR.

Summary

The scheduled reconcile-versions run at 12:28 UTC on 2026-12-04 failed in its "Validate the publishing configuration" step: label with name "docs-archive-drift" already exists; use --force to update its color and description. The step checks for each tracking label with gh label list --search and creates it only when the search finds nothing. The label does exist (created 2026-09-21), and the same search returns it now, so the search missed it once. GitHub's search is not strongly consistent. The failed step stopped the run before it compared GitHub with the manifest, so that run reconciled nothing and the next scheduled run is the next chance, about 18 hours later at twice a day.

Fix

Create each label with gh label create ... --force, which creates it or updates its colour and description, and so cannot fail on a label that exists. This replaces the search-then-create check in the reconciler's ensure_label and note_on helpers and in the weekly header check in security.yml, which had the same pattern. --force also rewrites the live docs-archive-drift description from "hourly reconciler" to the text in the workflow ("twice-daily reconciler"), which is harmless.

workflow-labels.test.mjs fails on any workflow that creates a label without --force or searches for one before creating it. It fails on main and passes here.

QA

Nothing to see on the site. After this merges, the next reconcile-versions run should pass its "Validate the publishing configuration" step: https://github.com/coder/docs-engine/actions/workflows/reconcile-versions.yml

Pages to compare

What to check Production Preview
Nothing changes on the site https://coder.com/docs/ No preview; this changes workflows only

Testing

node --test scripts/workflow-labels.test.mjs scripts/workflow-secrets.test.mjs in apps/docs: 13 pass. actionlint is not installed here, so CI's run is the check.

Upstream

No. This is this repository's own workflow glue.


🤖 Built with AI assistance.

The reconciler's validation step looked a label up with `gh label list --search`
and created it when the search found nothing. GitHub's label search is not
always consistent, so on 2026-12-04 it missed an existing label, `gh label
create` failed with "already exists", and the whole scheduled run failed before
it compared anything. Create each label with `--force`, which creates or updates
it, in the reconciler's two label helpers and the weekly header check, and pin
that with a test over every workflow.

Assisted-by: AI
@nickvigilante
nickvigilante marked this pull request as ready for review December 4, 2026 17:24
@nickvigilante
nickvigilante requested a review from a team as a code owner December 4, 2026 17:24

@Jesswinters Jesswinters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. I found no P0 or P1 problems. gh label create --force creates the label or updates it, so it removes the list-then-create race in all three places it occurred. The new test guards against the pattern coming back. actionlint, lint & typecheck, and the @coder/docs-site tests pass. axe accessibility pass was still running and deploy preview was waiting when I approved.

Optional nits:

  1. Header comment is now slightly stale. .github/workflows/reconcile-versions.yml lines 35-36 say the label "is created when it is absent". It is now created or updated on every run. Something like "created, or its colour and description reset, on every run" would match the new behavior.
  2. --force reverts manual label edits. Anyone who changes the colour or description of docs-archive-drift, code-server-pin-behind, or security-header-drift in the GitHub UI will see the change undone on the next run. That is fine, but a short comment by ensure_label ("the workflow owns these labels' colour and description") would save someone a confusing moment.
  3. The test reads one line at a time. In apps/docs/scripts/workflow-labels.test.mjs:
    • Line 22: a gh label create that is split with \ and has --force on the next line fails the test even though it is correct. This fails safe, so it only matters if someone wraps the command.
    • Line 29: it only catches gh label list ... --search on one line. A check such as gh label list | grep -qx without --search is the same race and would pass. Matching gh label list alone may be stricter than you want, so this is your call.
    • Line 7: it scans only .github/workflows. If composite actions under .github/actions ever create labels, they are not covered.
  4. "daily" vs "twice a day". The label description and the file header say "daily reconciler", but the schedule runs at 06:17 and 12:17 UTC. Since --force now rewrites the live description anyway, this is a good time to make it accurate if you care.

Coder Agents generated this review for @Jesswinters.

Update the reconcile workflow's header comment for labels that are created or
reset on every run, note beside `ensure_label` that `--force` resets a label
edited by hand, and call the reconciler "twice-daily" in the label description
to match its 06:17 and 12:17 UTC schedule.

Assisted-by: AI
@nickvigilante

Copy link
Copy Markdown
Collaborator Author

Applied nits 1, 2 and 4 in 3052477: the header comment now says labels are created or reset on every run, a line by ensure_label says the workflow owns the colour and description, and the label description says "twice-daily reconciler". Left nit 3 alone: the test fails safe on a wrapped command, and widening it to gh label list or .github/actions is a separate decision.


🤖 Built with AI assistance.

@nickvigilante

Copy link
Copy Markdown
Collaborator Author

@Jesswinters thanks for the review. Here is what I did with each nit.

Nits 1, 2 and 4 are in 3052477: the header comment now says labels are created or reset on every run, a line by ensure_label says the workflow owns the colour and description, and both label descriptions say "twice-daily reconciler" to match the 06:17 and 12:17 UTC schedule.

I did not change the test for nit 3, for three reasons. The wrapped gh label create fails safe: a false failure points at the line, and fixing it means rejoining it. A gh label list | grep -qx without --search is not the bug this PR fixes, because the failure was the check-then-create order, and the first test requires every gh label create to carry --force, which cannot fail on a label that already exists; so a list ahead of a create is now harmless whether or not it searches. And no composite action under .github/actions touches labels today (I searched for gh label and found none). Widening the test to cover wrapped commands and that directory is cheap, so I logged it as a low-priority follow-up rather than lose it.


🤖 Built with AI assistance.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Docs preview deployment

Rendered with docs-engine 352f389 from coder/coder at 2d87c26121435613bc421e4d18154ff83f43d3b9: https://coder-docs-m6qk5y92h.coderite.app

The preview is behind Vercel authentication; sign in with your Coder Vercel account.

@nickvigilante
nickvigilante merged commit aae6c1c into main Dec 4, 2026
37 checks passed
@nickvigilante
nickvigilante deleted the vigilante/reconcile-label-race branch December 4, 2026 17:41

This branch was successfully deployed

1 active deployment
docs-preview — 30524776 Deployed Dec 4, 2026 by nickvigilante via preview / deploy preview #158
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants