Skip to content

Add github action to verify compat flags have docs#6518

Merged
jasnell merged 1 commit intomainfrom
jasnell/add-compat-flag-doc-action
Apr 21, 2026
Merged

Add github action to verify compat flags have docs#6518
jasnell merged 1 commit intomainfrom
jasnell/add-compat-flag-doc-action

Conversation

@jasnell
Copy link
Copy Markdown
Collaborator

@jasnell jasnell commented Apr 7, 2026

No description provided.

@jasnell jasnell requested review from danlapid, guybedford and npaun April 7, 2026 23:30
@jasnell jasnell requested review from a team as code owners April 7, 2026 23:30
@jasnell jasnell requested a review from ascorbic April 7, 2026 23:30
Comment thread .github/workflows/compat-flag-docs.yml Fixed
@jasnell jasnell force-pushed the jasnell/add-compat-flag-doc-action branch from 26351b1 to 5d20d94 Compare April 7, 2026 23:32
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

This PR adds a GitHub Action that verifies new compat flags with default-on dates have corresponding documentation in cloudflare-docs. The Python script parses compatibility-date.capnp, diffs against the base branch, and uses gh CLI to check for docs on the production branch or in approved open PRs. A test flag (justATestThisWontBeLanded) is included to exercise the check.

Findings (highest severity first):

  1. [HIGH] github.token lacks cross-repo read access — The default GITHUB_TOKEN is scoped to cloudflare/workerd. Calls to gh api repos/cloudflare/cloudflare-docs/contents/... and gh search prs --repo cloudflare/cloudflare-docs will likely 404 or 403 because the token has no read permission on cloudflare/cloudflare-docs. You'll need a PAT or a GitHub App token with cross-repo contents:read scope. If this already works due to an org-level policy, a comment explaining that would be helpful.

  2. [MED] merge_group event sets GITHUB_BASE_SHA to empty string — For merge_group events, github.event.pull_request.base.sha is not populated and will evaluate to an empty string. The script's resolve_base_sha() correctly falls back through GITHUB_EVENT_PATH and git merge-base, but passing an empty-string env var means the first branch (os.environ.get("GITHUB_BASE_SHA")) returns "" which is truthy in Python, so git show :src/workerd/io/compatibility-date.capnp runs (no commit ref) and the fallback never triggers.

  3. [MED] Script collects experimental status but never uses itparse_compat_flags records "experimental": is_experimental for each flag, but this value is never checked. Should experimental flags be exempt from the documentation requirement? If so, the check should skip them; if not, the field should be removed to avoid confusion.

  4. [LOW] $compatEnableAllDates is not detected — The script checks for $compatEnableDate and $impliedByAfterDate as triggers for requiring docs, but $compatEnableAllDates (which makes a flag default-on for all dates) is not handled. Currently only one flag uses it (r2PublicBetaApi), so this is low-impact, but worth noting for completeness.

  5. [LOW] Missing permissions block in workflow — CodeQL already flagged this. Adding an explicit permissions block (e.g. contents: read) is best practice for least-privilege.


This review was generated by an AI assistant and may contain inaccuracies.

Comment thread .github/workflows/compat-flag-docs.yml
Comment thread .github/scripts/check-compat-flag-docs.py
Comment thread .github/scripts/check-compat-flag-docs.py
Comment thread .github/workflows/compat-flag-docs.yml
Comment thread .github/workflows/compat-flag-docs.yml
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 7, 2026

I'm Bonk, and I've done a quick review of your PR.

Review posted on PR #6518 with 5 findings and inline comments with suggestions:

  1. [HIGH] github.token lacks cross-repo read access — the default GITHUB_TOKEN can't query cloudflare/cloudflare-docs unless there's an org-level policy.
  2. [MED] merge_group events pass empty string as GITHUB_BASE_SHA, which is truthy in Python, causing resolve_base_sha() to skip its fallback logic and git show to read from the index instead of the actual base.
  3. [MED] is_experimental is collected in parse_compat_flags but never used — unclear whether experimental flags should be exempt from the docs requirement.
  4. [LOW] $compatEnableAllDates is not detected as a trigger for requiring documentation.
  5. [LOW] Missing permissions block in the workflow (also flagged by CodeQL).

github run

Copy link
Copy Markdown
Member

@npaun npaun left a comment

Choose a reason for hiding this comment

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

See also #5839

@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Apr 7, 2026

I thought the idea sounded familiar ;-) ... I'm good with either one landing.

Copy link
Copy Markdown
Collaborator

@harrishancock harrishancock left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me, though Bonk seems to have some smart comments.

Comment thread .github/scripts/check-compat-flag-docs.py
Comment thread .github/scripts/check-compat-flag-docs.py
@jasnell jasnell merged commit 9f223a1 into main Apr 21, 2026
34 checks passed
@jasnell jasnell deleted the jasnell/add-compat-flag-doc-action branch April 21, 2026 16:58
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.

4 participants