Skip to content

fix(settings): validate PORT instead of silently defaulting to 3000 - #5129

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/validate-port-env-var
Jul 23, 2026
Merged

fix(settings): validate PORT instead of silently defaulting to 3000#5129
pedrofrxncx merged 1 commit into
mainfrom
fix/validate-port-env-var

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Follows #5123, which hardened DATABASE_POOL_MAX to reject malformed values via a new toPositiveIntegerOrDefault helper instead of silently defaulting. port in the same resolveConfig function still had the old pattern: Number(flags.port) || Number(envVars.PORT) || 3000.

Payoff: a typo'd or malformed PORT (e.g. PORT=abc, PORT=-1, PORT=0) currently falls back to 3000 with zero warning, so a deploy silently binds to the wrong port instead of failing fast at startup — exactly the class of bug #5123 just fixed for the pool-size setting.

Fix: reuse the existing toPositiveIntegerOrDefault helper for port, keeping the --port flag > PORT env var precedence, defaulting to 3000 only when neither is set, and throwing PORT must be a positive integer otherwise.

Reviewer check: cd apps/mesh && bun test src/settings/resolve-config.test.ts

Verified locally: bun run fmt, bunx tsc --noEmit (apps/mesh workspace), and the targeted test file above (32 pass). Full CI runs the rest.


Summary by cubic

Validate PORT in mesh config and fail fast on invalid values instead of silently defaulting to 3000. Keeps --port > PORT precedence and only defaults to 3000 when both are unset.

  • Bug Fixes
    • Use toPositiveIntegerOrDefault("PORT", flags.port || envVars.PORT, 3000) in resolveConfig.
    • Throw a clear error for invalid values (e.g., "abc", "0", "-1", "1.5", "Infinity").
    • Add tests for defaulting, env/flag precedence, and invalid inputs.

Written for commit ce6fcc3. Summary will update on new commits.

Review in cubic

A malformed PORT (non-numeric, zero, negative, non-integer) silently
falls back to 3000 today via `Number(envVars.PORT) || 3000`, masking
a misconfiguration instead of failing loudly. Reuses the
toPositiveIntegerOrDefault helper #5123 introduced for
DATABASE_POOL_MAX to apply the same validation here.
@pedrofrxncx
pedrofrxncx merged commit 3f90793 into main Jul 23, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/validate-port-env-var branch July 23, 2026 20:30
decocms Bot pushed a commit that referenced this pull request Jul 23, 2026
PR: #5129 fix(settings): validate PORT instead of silently defaulting to 3000
Bump type: patch

- decocms (apps/mesh/package.json): 4.112.0 -> 4.112.1

Deploy-Scope: server
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