fix(ci): resolve every dangling env reference and drop the dead media path
What & why
An audit of every vars.* and secrets.* reference in the deploy workflows against what actually exists in GitHub. Three findings, all the same shape — configuration that claims to be needed and isn't, or is needed and isn't there.
1. MEDIA_URL_DEV never existed. deploy-preview.yml referenced it twice, and an unset variable expands to an empty string, so every preview deploy passed MEDIA_URL= and booted anyway because the schema said .optional(). The failure moved from the deploy, where it's visible, to the first attachment call. Same class as the STATIC_URL_DEV break earlier today, except STATIC_URL is required so that one failed loudly.
2. BLAXEL_REGION and BLAXEL_SANDBOX_IMAGE had been moved to secrets, but the workflows still read them as vars.*. Both are z.string().min(1), so the next deploy would have failed at boot validation. No deploy ran in the window — this was waiting to happen, not already broken.
3. NEXT_PUBLIC_SENTRY_ENVIRONMENT was referenced as a variable and has never existed as one. Optional, so it didn't fail; it quietly labelled every production Sentry event with no environment. Now a scoped secret.
MEDIA_URL is removed, not required
This started as "make MEDIA_URL required." Following the callers showed that was wrong: lib/files/tickets.ts was its only reader in this package, and nothing called either of that file's exports. mediaBaseUrl and mintFileTicket are the file-viewer work that was dropped.
Requiring an env var that no consumer reads is worse than the guard it replaced — it forces every environment to configure something unused. So the dead file, its barrel export, the schema entry, eight workflow lines, both template entries and the two environment secrets are gone.
The usercontent Worker keeps its own MEDIA_URL from wrangler.jsonc vars. That was never the same variable.
Also
USERCONTENT_URLandUSERCONTENT_TOKEN_SECRETare now genuinely required, and the three.optional()+if (!env.X) throwguards they existed to satisfy are deleted. That pairing is required-in-disguise, whichdocs/environment-variables.mdalready warns against.usercontentBaseUrl()andticketSecret()were wrappers whose entire body becamereturn env.Xonce the guards came out. Their five call sites readenvdirectly now.signFileTicketis deliberately left: its verifying half is still live in the Worker's media route, and deleting one side of that pair is a larger decision than this PR.
How I tested it
bun run typecheck,bun run lint,bun run --cwd packages/i18n check— all pass.bun test packages/trpc packages/shared— 1041 pass, 0 fail.- Audited every
vars.*reference against existing variables, and everysecrets.*reference against existing repo/Production/Preview secrets. Both come back clean; before this they did not. - Verified
MEDIA_URLhas zero remaining references in workflows before deleting its secrets.
The preview deploys on this PR are the live check: USERCONTENT_URL and USERCONTENT_TOKEN_SECRET are now required, so a secret that failed to resolve would fail the deploy rather than surface later.
Known gap
Preview media still won't serve. The dev Worker answers on a single workers.dev host and apps/usercontent/src/index.ts:218 splits media from frame by hostname. Separate work, and now largely moot for the API since nothing mints file tickets.
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (CI fails on lint warnings too) - "Allow edits from maintainers" is checked on fork PRs
https://claude.ai/code/session_01QAQLVm3xTUXsJhpPQo3Nuf
Summary by CodeRabbit
- Bug Fixes
- Improved deployment security by sourcing sensitive user-content and monitoring configuration from protected settings.
- Deployments now fail early when required user-content or security settings are missing or invalid.
- Improved reliability of page content, file, and thumbnail access through consistent user-content configuration.
- Updated preview and production deployments to use consistent configuration handling and removed obsolete media configuration.