Skip to content

Fix HTTP transport and isolate branch previews - #419

Open
admdly wants to merge 11 commits into
mainfrom
codex/preview-http-transport
Open

admdly wants to merge 11 commits into
mainfrom
codex/preview-http-transport

Conversation

@admdly

@admdly admdly commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Use HTTP transport to read synthetic data from the fixed staging API, preserving native fetch's global receiver. Enable Preview sign-in with a dedicated OAuth client, separate from localhost development. The trusted workflow on main reconciles exact live branch and named staging callbacks after successful Cloudflare builds, branch deletion and hourly cleanup; GitHub Actions OIDC restricts updates to that preview client.

Both staging deployments are named Previews under the existing api and extensions Workers. The directory's existing Cloudflare main build deploys production and then wrangler preview --name staging, reusing one build. Staging is available at https://staging-extensions.fossbilling.workers.dev, using https://staging-api.fossbilling.workers.dev. Deploy FOSSBilling/auth#81 and configure EXTENSIONS_PREVIEW_CLIENT_ID before activating callback reconciliation. FOSSBilling/api#321 keeps the API current and sends staging cache invalidations over HTTP.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-14T19:50:04.118388Z 1566558 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 1 file

Auto-approved: Wraps globalThis.fetch so the Workers HTTP API transport retains fetch's global receiver, fixing a TypeError during identity sync; focused one-line bug fix with tests passing.
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

Turn on auto-fix | Re-trigger cubic

@admdly admdly changed the title Fix HTTP API transport in Workers Fix HTTP transport and isolate branch previews Nov 10, 2026
cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes Nov 10, 2026

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 3 files (changes from recent commits).

Auto-approved: Fixes the HTTP transport fetch binding and isolates branch previews to the staging API with synthetic data; remaining changes are docs and regenerated Wrangler types. Bounded to preview configuration plus a focused bug fix.

Turn on auto-fix | Re-trigger cubic

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://codex-preview-http-transport-extensions.fossbilling.workers.dev (commit c161ff5)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://458c1172-extensions.fossbilling.workers.dev c161ff5 2026-11-14T19:52:22.407Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://c3487817-extensions.fossbilling.workers.dev 1566558 2026-11-14T19:46:48.858Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://355610f0-extensions.fossbilling.workers.dev dee45ce 2026-11-14T15:09:21.339Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://f7bcedde-extensions.fossbilling.workers.dev 9459caa 2026-11-14T15:07:23.356Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://d84e167a-extensions.fossbilling.workers.dev fef26cd 2026-11-14T14:27:33.515Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://54cf2cbf-extensions.fossbilling.workers.dev 9582585 2026-11-14T11:31:27.402Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://a0ad7442-extensions.fossbilling.workers.dev 7cc4f95 2026-11-14T10:47:09.399Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://386268d6-extensions.fossbilling.workers.dev f6d9ea6 2026-11-12T10:24:02.823Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://5b9070bf-extensions.fossbilling.workers.dev 1e2df6c 2026-11-10T16:08:27.856Z Visit the dashboard ↗

@admdly admdly self-assigned this Nov 10, 2026

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread test/cloudflare-platform.test.ts Resolved
@cubic-dev-ai
cubic-dev-ai Bot dismissed their stale review November 14, 2026 10:49

Dismissed because Cubic found issues in a newer review.

@admdly
admdly marked this pull request as draft November 14, 2026 11:31

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 4 files (changes from recent commits).

Requires human review: Adds OIDC-based callback reconciliation for branch Previews, switches Previews to a staging API/dev OAuth client, and fixes the HTTP fetch receiver. The new auth-service integration and preview exposure are the decisive human decisions.

Turn on auto-fix | Re-trigger cubic

@admdly
admdly marked this pull request as ready for review November 14, 2026 19:47

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/sync-preview-callbacks.ts">

<violation number="1" location="scripts/sync-preview-callbacks.ts:48">
P1: The Preview API is being addressed with `script.tag`, which is an immutable deployed script tag rather than the `extensions` Worker name. Use the configured Worker name/ID for `/workers/workers/{worker}/previews`; otherwise the workflow cannot read previews and never reconciles callbacks.</violation>

<violation number="2" location="scripts/sync-preview-callbacks.ts:66">
P2: A Preview without a routable `urls` array crashes reconciliation at `flatMap`, preventing all callback updates. Treat missing URLs as empty with `preview.urls ?? []` and model the field as optional.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

for (let page = 1; ; page++) {
const data = await readJson<Page<Preview>>(
fetcher,
`${base}/workers/workers/${service.result.default_environment.script.tag}/previews?per_page=100&page=${page}`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: The Preview API is being addressed with script.tag, which is an immutable deployed script tag rather than the extensions Worker name. Use the configured Worker name/ID for /workers/workers/{worker}/previews; otherwise the workflow cannot read previews and never reconciles callbacks.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/sync-preview-callbacks.ts, line 48:

<comment>The Preview API is being addressed with `script.tag`, which is an immutable deployed script tag rather than the `extensions` Worker name. Use the configured Worker name/ID for `/workers/workers/{worker}/previews`; otherwise the workflow cannot read previews and never reconciles callbacks.</comment>

<file context>
@@ -0,0 +1,110 @@
+  for (let page = 1; ; page++) {
+    const data = await readJson<Page<Preview>>(
+      fetcher,
+      `${base}/workers/workers/${service.result.default_environment.script.tag}/previews?per_page=100&page=${page}`,
+      options.cloudflareToken,
+    );
</file context>

preview.name === 'staging' ||
(preview.name !== 'main' && branches.has(preview.name)),
)
.flatMap((preview) => preview.urls)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: A Preview without a routable urls array crashes reconciliation at flatMap, preventing all callback updates. Treat missing URLs as empty with preview.urls ?? [] and model the field as optional.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/sync-preview-callbacks.ts, line 66:

<comment>A Preview without a routable `urls` array crashes reconciliation at `flatMap`, preventing all callback updates. Treat missing URLs as empty with `preview.urls ?? []` and model the field as optional.</comment>

<file context>
@@ -0,0 +1,110 @@
+            preview.name === 'staging' ||
+            (preview.name !== 'main' && branches.has(preview.name)),
+        )
+        .flatMap((preview) => preview.urls)
+        .map((origin) => new URL('/auth/callback', origin).href),
+    ),
</file context>
Suggested change
.flatMap((preview) => preview.urls)
.flatMap((preview) => preview.urls ?? [])

This branch has not been deployed

No deployments
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.

1 participant