Skip to content

Provision GitHub gatekeeper OAuth credentials in previews - #419

Open
Maximo-Guk wants to merge 1 commit into
kenton/worktreesfrom
maximo/preview-github-oauth-secrets
Open

Provision GitHub gatekeeper OAuth credentials in previews#419
Maximo-Guk wants to merge 1 commit into
kenton/worktreesfrom
maximo/preview-github-oauth-secrets

Conversation

@Maximo-Guk

@Maximo-Guk Maximo-Guk commented Sep 2, 2026

Copy link
Copy Markdown
Member

Uploads CLIENT_ID/CLIENT_SECRET to the GitHub gatekeeper's Previews settings when PREVIEW_GITHUB_CLIENT_ID/PREVIEW_GITHUB_CLIENT_SECRET are set, so the connector works in a preview instead of throwing "not configured".

The GitHub gatekeeper deploys into every preview unconfigured today, so
connecting it there throws "The GitHub gatekeeper is not configured." on
the first click. Upload CLIENT_ID/CLIENT_SECRET to that worker's Previews
settings when a preview OAuth app is configured, the same way and for the
same reason the backend's admins and Access pair already travel: Wrangler
prints what it finds in a config, and this workflow's logs are public.

The pair is resolved before any config is written, so a renamed secret
fails the deploy rather than a preview, and is uploaded before the
gatekeeper's own preview, since a preview inherits the Previews settings
that exist when it is created. uploadBackendSecrets was already the whole
of that dance, including the baseline self-heal, so it becomes
uploadPreviewSecrets and takes the worker.

Optional per gatekeeper, unlike the Access pair: unset, the preview still
deploys and only that connector is dead. Half-set throws.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the delivery Changes to CI or release delivery label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Preview: pr419-maximo-previe-6baab739

https://pr419-maximo-previe-6baab739-router.cloudflare-os-previews.workers.dev

Dashboard · deleted when this PR closes

// Before this gatekeeper's preview, not after, and for the same reason the backend's go
// before its own: a preview inherits the Previews settings that exist when it is created.
const oauth = oauthApps.get(pkg.name);
if (oauth) await uploadPreviewSecrets(pkg, wrangler.command, oauth);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When both repository secrets are later unset, oauth is absent and this skips reconciliation entirely. The pinned Wrangler preview secret bulk command merge-patches the worker Preview defaults, so omitted keys are preserved; every future GitHub preview will therefore keep inheriting the old credentials despite the resolver claiming the connector is unconfigured. Please explicitly upload CLIENT_ID: null and CLIENT_SECRET: null (or otherwise delete those defaults) for the unconfigured case.

@ask-bonk

ask-bonk Bot commented Sep 2, 2026

Copy link
Copy Markdown

Posted 1 actionable inline finding.

github run

@Maximo-Guk
Maximo-Guk marked this pull request as ready for review September 2, 2026 02:54

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 potential issue.

Devin Review

Comment on lines +637 to +638
console.warn(`${envPrefix}_CLIENT_ID is unset: ${pkgName} is deployed unconfigured, and ` +
"connecting it in this preview will fail.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Removed OAuth credentials remain active

When both repository secrets are removed, addOAuthApp leaves no cleanup instruction, so deployment skips this worker. Existing Preview settings retain the old OAuth credentials.

Prompt for agents
Treat an explicitly unconfigured GitHub OAuth app as desired empty state, not as no work. scripts/preview/staging-config.ts currently omits gatekeeper-github from resolveGatekeeperSecrets when both environment values are absent, and scripts/preview/preview.ts interprets omission by skipping all Wrangler secret operations. Worker-level Preview settings survive deployments, so previously uploaded CLIENT_ID and CLIENT_SECRET remain inherited. Extend the resolved state and deployment flow to delete both Preview secrets when absent, while preserving pair validation and handling a missing baseline worker safely. Add a test covering a transition from configured to unconfigured settings.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delivery Changes to CI or release delivery

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant