Skip to content
This repository was archived by the owner on Oct 2, 2026. It is now read-only.

Commit ecbd6d7

Browse files
Fix semaphore preview 522: restore baseUrl in migrated config
The apps/semaphore config migration rewrote AppConfig as a fresh z.object({...}) instead of BaseAppConfig.extend({...}), silently dropping the inherited baseUrl field. alchemy's IterateApp derives the worker route and proxied DNS from runtimeConfig.baseUrl (deriveWorkerRouteHosts); with baseUrl undefined it created no route, so semaphore.<base> resolved via DNS but had no worker bound and Cloudflare answered 522. That 522 failed the preview readiness poll and reported as a generic "Failed to deploy" — the os worker itself was healthy throughout. Restore baseUrl: publicValue(z.url().optional()) (the Doppler config already supplies APP_CONFIG_BASE_URL). Document the diagnosis in the decisions log. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent adb759e commit ecbd6d7

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎apps/os/docs/simplification-decisions.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,29 @@ Two findings worth keeping:
166166
is almost certainly preview-infra (WS on preview wildcard hosts), not the
167167
refactor — flagged for follow-up confirmation, not claimed fixed.
168168

169+
- **`Preview / deploy` red was `apps/semaphore`, not `apps/os` — a dropped
170+
`baseUrl` in the migrated config.** On PR #1411 the deploy job failed at
171+
`scripts/preview/router.ts:113` after a ~9-minute silent gap (the readiness
172+
poll's 10-min budget, `preview.ts:43`). The misleading part: `os`'s readiness
173+
passed (`status: awaiting-tests`); the recorded state showed **semaphore**
174+
`deploy-failed` with `Readiness check returned 522 for
175+
https://semaphore.iterate-preview-2.com/api/__internal/health`. The semaphore
176+
worker was healthy on its `*.workers.dev` URL (200) but the custom hostname
177+
answered 522. Root cause: this PR rewrote `apps/semaphore/src/config.ts` as a
178+
fresh `z.object({...})` instead of `BaseAppConfig.extend({...})`, dropping the
179+
inherited `baseUrl` field. `IterateApp` derives the worker route + proxied DNS
180+
from `runtimeConfig.baseUrl` (`deriveWorkerRouteHosts`,
181+
`packages/shared/src/alchemy/iterate-app.ts`); with `baseUrl` undefined it
182+
created no route, so the leftover hostname resolved via DNS but had no worker
183+
bound → Cloudflare 522. Fix: add `baseUrl: publicValue(z.url().optional())`
184+
back to the schema (the Doppler config already supplies `APP_CONFIG_BASE_URL`).
185+
Lessons: (1) when a deploy "hangs" then fails, read the recorded preview state
186+
for the _per-app_ status and message — the failing app may not be the one you
187+
changed most; (2) a 522 on a custom hostname that's 200 on `workers.dev` is a
188+
missing/unbound worker route, not a worker bug; (3) replacing a
189+
`BaseAppConfig.extend(...)` with a hand-written object silently drops the base
190+
fields the platform depends on — prefer extending the base.
191+
169192
## Learnings
170193

171194
- An unauthenticated debug endpoint that echoes `process.env` is a secret leak

‎apps/semaphore/src/config.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { z } from "zod";
1111
* `.exposeSecret()` and never serialize their value.
1212
*/
1313
export const AppConfig = z.object({
14+
// alchemy's IterateApp derives the worker route + proxied DNS record from
15+
// baseUrl (deriveWorkerRouteHosts in packages/shared/src/alchemy/iterate-app.ts).
16+
// Drop it and the custom hostname (semaphore.<base>) keeps resolving via DNS
17+
// but has no route bound to the worker, so Cloudflare answers 522.
18+
baseUrl: publicValue(z.url().optional()),
1419
logs: AppLogsConfig.default({ stdoutFormat: "pretty", filtering: { rules: [] } }),
1520
posthog: z.object({
1621
apiKey: publicValue(z.string().trim().min(1)),

0 commit comments

Comments
 (0)