Copying .env.example to .env as documented cannot start the builder: REALTIME_BROADCAST_SECRET ships 9 characters against a min(32) schema
Summary
CONTRIBUTING.md:43 step 5 and AGENTS.md:73 both tell a new contributor to copy .env.example to .env. Doing exactly that leaves the builder unable to start: .env.example:146 ships REALTIME_BROADCAST_SECRET=secretkey (9 characters), while packages/partysocket-config/src/keys.ts:7 declares REALTIME_BROADCAST_SECRET: z.string().min(32). apps/builder/src/env.ts pulls that schema in through extends: [partysocket(), database(), mail()], so the failure happens during env validation, before any application code runs.
What isolates it. This is not "the example file is full of placeholders that all need replacing". Three secrets in the tree are declared z.string().min(32), and the other two already ship example values that validate:
| Variable | Declared in | .env.example value length |
min(32) |
|---|---|---|---|
BETTER_AUTH_SECRET |
apps/builder/src/env.ts:18 |
44 | passes |
JAVASCRIPT_EXECUTOR_TOKEN |
apps/javascript-executor/src/env.ts:6 |
41 | passes |
REALTIME_BROADCAST_SECRET |
packages/partysocket-config/src/keys.ts:7 |
9 | fails |
So the file is meant to be usable as-is for local development, and this is the only value in it that is not. JAVASCRIPT_EXECUTOR_TOKEN=change-me-in-production-at-least-32-chars is a placeholder shape that already works in your own tree.
Environment
| Measured against | upstream/main = e4913ef2a |
| How | Read and ran the repository. No deployed instance involved |
| Scope | Only the repo-root .env.example. The tree's other example file, apps/mcp-server/.env.example, does not declare this variable (checked) |
Steps to reproduce
- Clone the repository and run
pnpm install(CONTRIBUTING.md steps 2 and 4). cp .env.example .env(CONTRIBUTING.md step 5).- Load the builder's server env — the schema composed in
apps/builder/src/env.ts, whichextendspackages/partysocket-config/src/keys.ts.
Expected: validation passes and the dev server starts. Actual: validation throws and nothing starts.
Evidence
Parsed the repository's own .env.example into process.env and imported packages/partysocket-config/src/keys.ts, which validates at module load. Exit codes were read directly, not through a pipe.
Before, with .env.example exactly as it is on e4913ef2a — exit 1:
REALTIME_BROADCAST_SECRET from the file = "secretkey" (length 9)
❌ Invalid environment variables: [
{
origin: 'string',
code: 'too_small',
minimum: 32,
inclusive: true,
path: [ 'REALTIME_BROADCAST_SECRET' ],
message: 'Too small: expected string to have >=32 characters'
}
]
After the patch below — exit 0:
REALTIME_BROADCAST_SECRET from the file = "change-me-in-production-at-least-32-chars" (length 41)
validation PASSES
Boundary control at 31 characters — exit 1, same too_small. The measurement therefore discriminates at exactly the declared minimum instead of accepting anything non-empty.
packages/partysocket-config on the patched tree: 5 test files / 75 tests passed, check-types clean, Cached: 0 (the run was not served from cache).
Where it comes from
.env.example:146—REALTIME_BROADCAST_SECRET=secretkeypackages/partysocket-config/src/keys.ts:7—REALTIME_BROADCAST_SECRET: z.string().min(32)apps/builder/src/env.ts:3and:13— imports those keys andextends: [partysocket(), database(), mail()]
secretkey appears three more times in the tree (DATABASE_URL, S3_SECRET_ACCESS_KEY, and the Compose defaults for Postgres and RustFS). None of them is this variable, so changing line 146 does not desynchronise any other component: apps/realtime's entrypoint reads the variable as ${REALTIME_BROADCAST_SECRET:?REALTIME_BROADCAST_SECRET is required} with no hardcoded default, and docs/realtime.md only names the variable, never a value.
Why we think this is a defect rather than the intended design
Step 5 reads "Copy .env.example to .env and configure your environment variables", which could be taken as "you were always meant to set a real secret here". Two things argue against that reading:
- The comment above the variable already says "MUST be overridden in production". The dev/production distinction is made deliberately, and in dev the example value is expected to work. The other two
min(32)secrets carry that same line and a value that validates. - Every other value in the file works out of the box for a local run: localhost URLs, the local Postgres DSN, a 64-character
ENCRYPTION_KEYgenerated for the example. This is the only value in the file that fails its own schema.
The symptom is also unhelpful: zod reports it as a too_small block that never mentions the value came from the shipped example, so the first thing a contributor suspects is their own setup.
Suggested fix
Give the example a value that satisfies the schema, reusing the placeholder shape already used in the same file for the sibling secret, and state the minimum in the comment:
# HMAC secret shared between builder and realtime to sign/verify
# short-lived (60s) JWTs sent as `Authorization: Bearer <token>`.
+# Minimum 32 characters. Generate with: openssl rand -base64 32
# MUST be overridden in production.
-REALTIME_BROADCAST_SECRET=secretkey
+REALTIME_BROADCAST_SECRET=change-me-in-production-at-least-32-chars
The value alone is the fix; the comment line is there so the constraint is visible where the value gets edited. Happy to drop it if you prefer the minimal diff.
Workaround for anyone hitting this
Set any value of 32 characters or more in .env before starting the builder, for example from openssl rand -base64 32. Verified: 41 characters passes, 31 still fails.
What we did not verify
- We did not boot the full stack. We ran the env schema that gates the boot — the module whose import throws — not
pnpm devwith Postgres, Redis and the realtime broker up. - We did not test the Docker Compose path, where the variable can be injected from the host environment before
.envis read. This report is about the.env.exampleto.envpath thatCONTRIBUTING.mdandAGENTS.mddocument. - We did not check whether
apps/realtimeand the worker fail at the same point or later. The builder is where we measured. - The numeric
min()constraints inapps/worker/src/env.tsall carry defaults and were not exercised.
Related issues — none of these describes it
Searched this repository's issues for REALTIME_BROADCAST_SECRET and for env.example. The only hit is #1169 (turbo run check-types cannot complete on an 8 GB machine), which is about heap during typechecking, not env validation. The search instrument was confirmed against a query that does return results, so the empty result for REALTIME_BROADCAST_SECRET is a real absence rather than a malformed query.