Skip to content

Feat/193 env config validation#245

Merged
determined-001 merged 3 commits intodetermined-001:mainfrom
Chrisbankz0:feat/193-env-config-validation
May 1, 2026
Merged

Feat/193 env config validation#245
determined-001 merged 3 commits intodetermined-001:mainfrom
Chrisbankz0:feat/193-env-config-validation

Conversation

@Chrisbankz0
Copy link
Copy Markdown
Contributor

#closes #193
This PR addresses the compounding ad-hoc validation of environment variables by centralizing them into a single typed configuration schema.

Previously, environment variables like NETWORK, PORT, API_KEY, and WEBHOOK_SECRET were validated disparately across index.ts, auth.ts, and registry.ts. This ad-hoc validation approach made it difficult to scale safely and predictably as new variables were planned to be introduced.

This PR ensures that all environment variables are parsed, strictly validated, and logged exactly once during server startup.

Changes Made

  • Added apps/server/src/config.ts: Created a centralized config module with a handwritten schema that extracts, validates, and exports a fully typed ServerConfig object.
  • Fail Fast Mechanism: The server now accumulates all validation errors (e.g., missing keys or invalid ports) and fails fast at boot with clear, actionable error messages.
  • Secure Boot Logging: Configuration variables are safely logged during startup to aid debugging, with sensitive credentials (API_KEY and WEBHOOK_SECRET) being automatically redacted.
  • Refactored Consumers: Stripped ad-hoc process.env checks from index.ts, auth.ts, and registry.ts, migrating them to securely consume the globally exported config object.

Testing Notes

  • Booting the server without NETWORK and API_KEY now results in a fatal error logging both missing variables.
  • Booting the server with PORT=abc throws a validation error for the port.
  • Booting with correct variables successfully logs NETWORK and PORT while rendering API_KEY and WEBHOOK_SECRET as ***REDACTED***.

#closes

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

Someone is attempting to deploy a commit to the determined's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@Chrisbankz0 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Removes duplicate inline NETWORK/PORT validation from index.ts and routes
all environment access through the typed config module, keeping pino logger
and graceful shutdown intact.
@determined-001 determined-001 merged commit 4a4a3c3 into determined-001:main May 1, 2026
2 of 3 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.

4.33 — Env var validation at startup with a typed schema

2 participants