Skip to content

feat(worker): validate env up front and normalise server URL - #380

Merged
davidmckayv merged 4 commits into
CopilotKit:mainfrom
Ayush7614:feat/worker-env-validation
Sep 5, 2026
Merged

feat(worker): validate env up front and normalise server URL#380
davidmckayv merged 4 commits into
CopilotKit:mainfrom
Ayush7614:feat/worker-env-validation

Conversation

@Ayush7614

Copy link
Copy Markdown
Contributor

The worker's three env guards used truthiness checks, so whitespace-only WORKER_SHARED_SECRET / SERVER_INTERNAL_URL / DATABASE_URL passed boot and then failed on every 30s tick (fetch to whitespace URLs, createDatabase on whitespace strings) as endless routine-sweep-tick-failed lines. A trailing-slash SERVER_INTERNAL_URL also built //internal/routines/run (404 reported only as 'answered 404 rather than 202'), and HOSTNAME='' produced the colliding owner 'routines/' the random fallback exists to avoid.

Change: new worker/src/env.ts with loadWorkerEnv() (trim + refuse whitespace like unset, strip trailing slashes, trim/fallback HOSTNAME) and routineRunUrl(); index.ts uses both. New worker/tests/env.test.ts (17 tests).

Verified: bun test worker/tests/ 18 pass; tsc clean for worker.

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-run after format fix (prior CI failure was a stale-run race on the pre-format sha). Current head passes format:check + full CI. Substance verified by composed build/tests + deep review.

@davidmckayv
davidmckayv merged commit 57a1b5f into CopilotKit:main Sep 5, 2026
14 checks passed
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.

2 participants