fix(github-mint): grant deployments:read so QA can read PR preview URLs - #6333
Merged
Merged
Conversation
The QA reviewer resolves a PR's `previewUrl` from four sources; for VTEX FastStore WebOps the preview is published ONLY as a GitHub Deployment, so the only source that finds it is the last-resort `GET_PREVIEW_DEPLOYMENT` call against the Deployments API. Repo-scoped connections mint their installation token from `GITHUB_SCOPED_PERMISSIONS`, which never requested `deployments`, so that call returned `403 Resource not accessible by integration` and `previewUrl` came back null (QA then had to boot the app itself to review). Add `deployments: "read"` to the scoped set and generalize the checks-only mint fallback into a permission-agnostic ladder (`mintRepoTokenWithFallback` + `OPTIONAL_MINT_PERMISSIONS`) that sheds optional reads one at a time on a permission rejection. An installation that grants `checks` but not the newer `deployments` keeps checks; one that grants neither still mints a working code token — so this can't 422-break import/refresh on installations that haven't re-approved the permission upgrade yet. Note: this takes full effect only once the deco GitHub App declares `deployments:read`, each org re-approves the installation, and github-mcp's MINT_REPO_TOKEN allowlist permits it. Until then the ladder degrades gracefully. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
decocms Bot
pushed a commit
that referenced
this pull request
Aug 20, 2026
PR: #6333 fix(github-mint): grant deployments:read so QA can read PR preview URLs Bump type: patch - decocms (apps/api/package.json): 4.245.2 -> 4.245.3 - @decocms/native (apps/native/package.json): 4.245.2 -> 4.245.3 - @decocms/shared (packages/shared/package.json): 0.46.4 -> 0.46.5 Deploy-Scope: both
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problema
O QA agent aprovou a faststoretorra#204 reportando
previewUrl: null— "check FastStore WebOps verde, mas a API de deployments retorna 403 para este token" — e teve que subir a aplicação no sandbox (bun run dev) para exercer a mudança, em vez de usar o preview da PR.Causa raiz.
TASK_BOARD_ITEM_PRS_GETresolve opreviewUrlde 4 fontes (apps/api/src/tools/task-board/prs-get.ts). Para VTEX FastStore WebOps o preview é publicado só como um GitHub Deployment — não comotarget_urlde commit-status nem comentário de bot — então a única fonte que o encontra é o último recursoGET_PREVIEW_DEPLOYMENT(Deployments API). Conexões repo-scoped mintam seu installation token a partir deGITHUB_SCOPED_PERMISSIONS, que nunca pediadeployments→ a chamada retorna403 Resource not accessible by integrationepreviewUrlvoltanull.Companheiro do decocms/mcps#535 (que adicionou a tool
GET_PREVIEW_DEPLOYMENT): a tool lê com o token do caller, e faltava concederdeployments:reada esse token.Correção
deployments: "read"aGITHUB_SCOPED_PERMISSIONS.mintRepoTokenWithChecksFallback) num ladder agnóstico de permissão (mintRepoTokenWithFallback+OPTIONAL_MINT_PERMISSIONS), que descarta um read opcional por vez (deployments, depoischecks) quando o mint é rejeitado especificamente por exceder o que a instalação/allowlist concede:checksmas sem o mais novodeployments→ mantém checks;withOptionalReadPermissionsself-heala recipes legadas no re-mint (~1h).Depende de (fora deste repo)
Só tem efeito pleno quando: (1) o GitHub App do deco declarar
deployments:read, (2) cada org reaprovar a instalação, e (3) o allowlist doMINT_REPO_TOKEN(github-mcp) permitirdeployments. Até lá o ladder degrada graciosamente (comportamento idêntico ao de hoje).Testes
packages/shared/src/github-repo-scope.test.ts— reescritos para o ladder: sucesso first-try, drop só de deployments (mantém checks), drop de ambos, erro não relacionado não descarta optionals, rejeição de permissão required só surfa depois que os optionals acabam.bun testverde (42 pass).bun run check(shared/api/web),bun run lint(0 erros),bun run fmt,knip— todos limpos para os símbolos alterados.🤖 Generated with Claude Code
Summary by cubic
Grant
deployments:readto repo-scoped tokens and add a permission-agnostic mint fallback so the PR panel can read PR preview URLs via GitHub Deployments. Previously we did not request deployments andGET_PREVIEW_DEPLOYMENT403’d, leavingpreviewUrlnull; now we request it and shed optional reads (deployments, then checks) only when the installation or allowlist rejects them.Review notes
deployments: "read"toGITHUB_SCOPED_PERMISSIONS; keeps existing write scopes.mintRepoTokenWithChecksFallbackwithmintRepoTokenWithFallback, driven byOPTIONAL_MINT_PERMISSIONSandwithOptionalReadPermissions.apps/api/src/oauth/github-mint.tsandapps/web/src/lib/provision-repo-scoped-github-connection.tsto use the new ladder; tokens self-heal optionals on re-mint.packages/shared/src/github-repo-scope.test.tsto cover deployments, ladder behavior, and non-downgrade errors.Rollout
deployments:read, have orgs re-approve the installation, and permitdeploymentsin theMINT_REPO_TOKENallowlist.checkswhen available.Written for commit 328c3c0. Summary will update on new commits.