Skip to content

docs(api): label the per-scope application key auth schemes - #12368

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/sileht/mrgfy-8646-api-reference-auth-scheme-labels/label-per-scope-app-key-auth-schemes--beb5562d
Aug 13, 2026
Merged

docs(api): label the per-scope application key auth schemes#12368
mergify[bot] merged 1 commit into
mainfrom
devs/sileht/mrgfy-8646-api-reference-auth-scheme-labels/label-per-scope-app-key-auth-schemes--beb5562d

Conversation

@sileht

@sileht sileht commented Aug 12, 2026

Copy link
Copy Markdown
Member

The /api reference renders each endpoint's accepted credentials from a
hardcoded map of security scheme name to prose, falling back to the raw
scheme name on a miss.

The engine is splitting the scope-blind ApplicationAuth scheme into
AdminApplicationKey and CIApplicationKey, so every endpoint on the
page would read as a camel-case identifier once that schema syncs here.

Add both labels. ApplicationAuth stays: public/api-schemas.json is
synced from the engine by a bot on its own schedule, so the shipped
schema still names it until that lands.

Verified against the regenerated schema rather than assumed: building
the site with it renders 61 "Admin Application Key", 14 "CI Application
Key" and 60 "GitHub Token" badges, and no raw scheme names.

Related to MRGFY-8646


Left out on purpose

Four things surfaced while verifying this. None are regressions from these
lines. Flagging rather than widening the diff.

  1. Open, but a copy decision — src/pages/api/index.astro:47 hardcodes
    "All endpoints require a Bearer token. Two authentication methods are
    supported: Application Key, GitHub Token". Once the schema syncs, the badges
    read Admin Application Key / CI Application Key, so the intro introduces
    a name the badges never use. Worth being precise: unlike Bump loader-utils from 1.4.0 to 1.4.2 #2 this is not
    factually wrong
    — there really are two auth methods, one of which has two
    scopes — it is a naming mismatch, which makes it lower priority. The right
    rewording depends on the same scope answer as Bump loader-utils from 1.4.0 to 1.4.2 #2, so it is deliberately not
    in this PR.

    Separately, the "All endpoints require a Bearer token" half of that sentence
    is already false on main, independent of any of this: GET /badges/{owner}/{repository}, .png and .svg publish no security at
    all. Pre-existing, belongs in the same rewrite whenever someone takes it.

  2. Not a docs fix — src/content/docs/api/usage.mdx:42 says the admin
    scope grants "Full access to all API endpoints", which the new schema
    contradicts: PUT and POST /repos/{owner}/{repository}/pulls/{number}/scopes
    declare CIApplicationKey only, and get_by_key_and_scopes filters on
    strict scope membership with no superset, so an admin key really is refused.
    Deliberately not touched here: whether admin ought to subsume ci is a
    product question. If the intent is "admin can do everything" then the engine
    is wrong and this line is right. Being raised with Mehdi on the monorepo side.

  3. Fixed at the source, no action here. Badge order was not deterministic:
    45 operations emitted (AdminApplicationKey, GitHubTokenBearerAuth) and 4
    the reverse, for the same OR-set. Now canonical for every operation in
    Mergifyio/monorepo#38586, plus the future and internal specs. My first guess
    at the cause was wrong — it is not set iteration in the new rewrite and it
    predates it: FastAPI emits requirements in dependency-resolution order, and
    the 4 outliers carry a delegation role whose injected guard takes the logged
    user before the application dependency. Fixed there rather than sorted here,
    so the live openapi.json and generated clients get it too.

  4. Noted, no action wanted. The engine ships a description per scheme
    ("admin scope, reaches every endpoint" / "ci scope, reaches CI Insights
    endpoints only", both linking to the usage page). Endpoint.astro renders
    only the badge label, so it does not surface on this page — correcting my
    earlier phrasing, that copy is not dead: it reaches
    api.mergify.com/v1/openapi.json, generated clients, and Scalar/Swagger-style
    renderers. Not rendering it here is the intended state.

I also skipped a test asserting every scheme in the shipped schema has a label.
It would turn the schemas-sync bot PR red for a cosmetic label and block the
config and CLI schema syncs riding along in it, in exchange for replacing a
graceful fallback with a hard failure.

Copilot AI lite review requested due to automatic review settings August 12, 2026 20:21
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 12, 2026 20:21 Failure
@mergify

mergify Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 6 merge protections satisfied — ready to merge.

Show 6 satisfied protections

🟢 🤖 Continuous Integration

  • all of:
    • check-success = build
    • check-success = lint
    • check-success = test
    • any of:
      • check-success = test-broken-links
      • label = ignore-broken-links
    • any of:
      • check-success=Cloudflare Pages
      • -head-repo-full-name~=^Mergifyio/

🟢 👀 Review Requirements

  • any of:
    • #approved-reviews-by >= 2
    • author = dependabot[bot]
    • all of:
      • author = mergify-ci-bot
      • -head ~= ^docs-agent/

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|internal|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?!?:

🟢 🔎 Reviews

  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

  • body ~= (?ms:.{48,})

🟢 🚦 Auto-queue

When all merge protections are satisfied, this pull request will be queued automatically.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the API reference’s authentication badge labeling to handle the engine’s upcoming split of the scope-blind ApplicationAuth scheme into scope-specific application key schemes, while keeping compatibility with the currently shipped schema.

Changes:

  • Extend the auth scheme label map to include AdminApplicationKey and CIApplicationKey (while retaining ApplicationAuth for backward compatibility).
  • Add unit tests covering the new labels and the existing “fallback to raw scheme name” behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/components/ApiReference/openapi.ts Adds labels for the new per-scope application key security scheme names so endpoint auth badges remain human-readable.
src/components/ApiReference/openapi.test.ts Adds targeted tests for the new auth scheme labels and the unmapped-scheme fallback behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/components/ApiReference/openapi.test.ts Outdated
@mergify
mergify Bot requested a review from a team August 12, 2026 20:24
The /api reference renders each endpoint's accepted credentials from a
hardcoded map of security scheme name to prose, falling back to the raw
scheme name on a miss.

The engine is splitting the scope-blind `ApplicationAuth` scheme into
`AdminApplicationKey` and `CIApplicationKey`, so every endpoint on the
page would read as a camel-case identifier once that schema syncs here.

Add both labels. `ApplicationAuth` stays: `public/api-schemas.json` is
synced from the engine by a bot on its own schedule, so the shipped
schema still names it until that lands.

Verified against the regenerated schema rather than assumed: building
the site with it renders 61 "Admin Application Key", 14 "CI Application
Key" and 60 "GitHub Token" badges, and no raw scheme names.

Related to MRGFY-8646

Change-Id: Ibeb5562dd6ac00add93d7ad201e112de95351ce7
@sileht

sileht commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

Revision history

# Type Changes Reason Date
1 initial 5961578 2026-08-12 20:24 UTC
2 content 5961578 → 45c1a98 2026-08-12 20:24 UTC

@sileht
sileht force-pushed the devs/sileht/mrgfy-8646-api-reference-auth-scheme-labels/label-per-scope-app-key-auth-schemes--beb5562d branch from 5961578 to 45c1a98 Compare August 12, 2026 20:24
@mergify
mergify Bot deployed to Mergify Merge Protections August 12, 2026 20:25 Active
@sileht
sileht marked this pull request as ready for review August 12, 2026 20:58
@mergify
mergify Bot requested a review from a team August 13, 2026 06:44
@mergify

mergify Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 3 minutes 58 seconds in the queue, including 2 minutes 39 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Aug 13, 2026
@mergify
mergify Bot merged commit 981b8a5 into main Aug 13, 2026
10 checks passed
@mergify
mergify Bot deleted the devs/sileht/mrgfy-8646-api-reference-auth-scheme-labels/label-per-scope-app-key-auth-schemes--beb5562d branch August 13, 2026 07:07
@mergify mergify Bot removed the queued label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants