Skip to content

fix: parse numeric environment variables to correct types#1886

Open
LautaroPetaccio wants to merge 2 commits into
mainfrom
fix/environment-config-type-parsing
Open

fix: parse numeric environment variables to correct types#1886
LautaroPetaccio wants to merge 2 commits into
mainfrom
fix/environment-config-type-parsing

Conversation

@LautaroPetaccio

Copy link
Copy Markdown
Contributor

Summary

Several numeric environment variables were stored as strings when set via process.env, but as numbers when using the default value. Consumers read them with getConfig<number>(...), which silently receives a string. JavaScript coercion often makes this work, but it causes incorrect behavior in strict comparisons and library APIs that expect numbers.

Changes in Environment.ts:

Config Fix
FOLDER_MIGRATION_MAX_CONCURRENCY Number(...) with fallback
HTTP_SERVER_PORT Number(...) with fallback
UPDATE_FROM_DAO_INTERVAL ms(... ?? '30m') to parse duration strings
DEPLOYMENTS_DEFAULT_RATE_LIMIT_MAX Number(...) with fallback
PSQL_PORT Number(...) with fallback
ENTITIES_CACHE_SIZE Number(...) with fallback
DEPLOYMENT_RATE_LIMIT_MAX per-entity parseInt(value!, 10) replacing value as any as number
RETRY_FAILED_DEPLOYMENTS_DELAY_TIME ms(... ?? '15m') to parse duration strings

Also fixes the requireNumber error message which incorrectly said "string" instead of "number".

Test plan

  • Set env vars like HTTP_SERVER_PORT=7070 and verify they're stored as numbers
  • Verify default values still work when env vars are unset
  • Run unit tests: cd content && npx jest test/unit/ --no-coverage

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.

1 participant