Skip to content

fix(config): throw on invalid/out-of-range port env vars#341

Merged
xlabtg merged 4 commits intoxlabtg:mainfrom
konard:issue-317-04e99ce2300e
Apr 23, 2026
Merged

fix(config): throw on invalid/out-of-range port env vars#341
xlabtg merged 4 commits intoxlabtg:mainfrom
konard:issue-317-04e99ce2300e

Conversation

@konard
Copy link
Copy Markdown

@konard konard commented Apr 23, 2026

Summary

Fixes #317loadConfig silently dropped invalid TELETON_WEBUI_PORT / TELETON_API_PORT values instead of failing fast.

  • Introduced parseEnvPort(name, value) that throws a descriptive error when the value is non-numeric or outside the valid 1–65535 range.
  • Replaced the two silent-ignore blocks (TELETON_WEBUI_PORT, TELETON_API_PORT) with calls to parseEnvPort, aligning them with the existing fail-fast behaviour of TELETON_TG_API_ID and TELETON_BASE_URL.
  • parseEnvPort is exported so callers and plugins can reuse it.

How to reproduce the issue

TELETON_WEBUI_PORT=abc teleton start   # was: bound on default port 7777 silently
                                        # now: throws Invalid TELETON_WEBUI_PORT

Regression tests added

Scenario Expected
TELETON_WEBUI_PORT=abc throws Invalid TELETON_WEBUI_PORT … not a valid integer
TELETON_WEBUI_PORT=99999 throws Invalid TELETON_WEBUI_PORT … out of valid port range
TELETON_WEBUI_PORT=8080 resolves to 8080
TELETON_API_PORT=abc throws Invalid TELETON_API_PORT … not a valid integer
TELETON_API_PORT=99999 throws Invalid TELETON_API_PORT … out of valid port range
TELETON_API_PORT=7778 resolves to 7778

All previously existing config loader tests continue to pass.

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: xlabtg#317
Introduce parseEnvPort(name, value) that throws a descriptive error
when TELETON_WEBUI_PORT or TELETON_API_PORT is non-numeric or outside
the 1–65535 range, aligning them with the existing fail-fast behaviour
of TELETON_TG_API_ID and TELETON_BASE_URL. Silently dropping a bad
port env was causing silent network misconfiguration in hardened
deployments.

Closes xlabtg#317
@konard konard changed the title [WIP] [AUDIT-FULL-L1] loadConfig silently drops invalid TELETON_WEBUI_PORT/TELETON_API_PORT fix(config): throw on invalid/out-of-range port env vars Apr 23, 2026
@konard konard marked this pull request as ready for review April 23, 2026 04:57
@konard
Copy link
Copy Markdown
Author

konard commented Apr 23, 2026

Solution summary

Done. Here's a summary of what was implemented:

Changes made:

  1. src/config/loader.ts — Added parseEnvPort(name, value) function that throws with a descriptive message when a port env var is non-numeric or outside 1–65535. Replaced the two silent-drop blocks for TELETON_WEBUI_PORT and TELETON_API_PORT with calls to this function, matching the existing fail-fast behavior of TELETON_TG_API_ID and TELETON_BASE_URL.

  2. src/config/__tests__/loader.test.ts — Updated the old "should ignore invalid TELETON_WEBUI_PORT" test to expect a throw, and added 6 regression tests covering the acceptance criteria from the issue (non-numeric throws, out-of-range throws, valid value succeeds — for both TELETON_WEBUI_PORT and TELETON_API_PORT).

PR: #341 (marked ready for review)


This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Author

konard commented Apr 23, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $1.215618

📊 Context and tokens usage:

  • 58.6K / 1M (6%) input tokens, 11.5K / 64K (18%) output tokens

Total: (48.0K + 2.9M cached) input tokens, 11.5K output tokens, $1.215618 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (1719KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Author

konard commented Apr 23, 2026

🔄 Auto-restart triggered (iteration 1)

Reason: CI failures detected

Starting new session to address the issues.


Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable.

@konard
Copy link
Copy Markdown
Author

konard commented Apr 23, 2026

🔄 Auto-restart-until-mergeable Log (iteration 1)

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $0.303026

📊 Context and tokens usage:

  • 34.8K / 1M (3%) input tokens, 3.1K / 64K (5%) output tokens

Total: (24.1K + 554.2K cached) input tokens, 3.1K output tokens, $0.303026 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (2251KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Author

konard commented Apr 23, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@xlabtg xlabtg merged commit e0d00b5 into xlabtg:main Apr 23, 2026
18 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.

[AUDIT-FULL-L1] loadConfig silently drops invalid TELETON_WEBUI_PORT/TELETON_API_PORT

2 participants