Skip to content

fix(config): honor $PORT directly (PR #2 follow-up)#3

Merged
aaronbrethorst merged 1 commit into
mainfrom
fixes
May 9, 2026
Merged

fix(config): honor $PORT directly (PR #2 follow-up)#3
aaronbrethorst merged 1 commit into
mainfrom
fixes

Conversation

@aaronbrethorst
Copy link
Copy Markdown
Member

Summary

  • Teaches internal/config to honor $PORT so deployments on Render/Heroku/Fly/Cloud Run don't need a hardcoded HOOKS_LISTEN_ADDR=:10000 envVar. New precedence: HOOKS_LISTEN_ADDR > yaml listen_addr > :$PORT > :8080.
  • Drops HOOKS_LISTEN_ADDR=:10000 from render.yaml; the platform-injected $PORT now drives the bind address automatically.
  • A set-but-unparseable PORT (typo, out-of-range, 0) errors at Parse time rather than silently falling back to :8080 — silent demotion would mask "service unreachable" failures behind a default the PaaS load balancer can't reach.

Resolves the follow-up flagged in PR #2: "Render PORT contract... The cleaner fix is to teach internal/config to honor $PORT directly."

Test plan

  • go test -race ./... — all packages pass
  • make lint — 0 issues
  • New table-driven TestListenAddrPrecedence covers 8 cases: PORT honored, yaml beats PORT, HOOKS_LISTEN_ADDR beats both, unset → default, and three error paths (non-numeric, out-of-range 70000, port 0)
  • Exercised the binary end-to-end:
    • PORT=12345 → server logs addr=:12345 and /readyz returns 200
    • PORT=garbage → refuses to start with config: PORT="garbage" is not a valid TCP port (1-65535)
    • PORT=70000 → same error path
    • HOOKS_LISTEN_ADDR=:23456 PORT=12345 → binds :23456 (override wins)

Review notes

  • An invalid PORT errors regardless of whether HOOKS_LISTEN_ADDR is also set — i.e. the env override does not "rescue" a typo'd PORT. This is intentional (loud-fail principle) and the operator can fix or unset PORT if they hit it. Happy to make HOOKS_LISTEN_ADDR short-circuit the validation if reviewers prefer that contract.
  • PORT=0 is rejected by the 1 <= n <= 65535 guard. Some Go programs use :0 to mean "OS picks an ephemeral port" via net.Listen; PaaS providers never inject 0, so locking it out is fine for this server but worth flagging.

…:10000

Resolves the PR #2 follow-up: render.yaml no longer needs to hardcode
HOOKS_LISTEN_ADDR=:10000 to match Render's $PORT default.

Listen-address precedence: HOOKS_LISTEN_ADDR > yaml listen_addr > $PORT > :8080.
A set-but-unparseable PORT errors at Parse time rather than silently demoting to
:8080 — silent demotion would mask "service unreachable" failures behind a
default that PaaS load balancers can't reach.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Warning

Rate limit exceeded

@aaronbrethorst has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 21 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a9cd5952-c0e8-44c5-ac2c-120a72441818

📥 Commits

Reviewing files that changed from the base of the PR and between 08cac0a and 24d5fad.

📒 Files selected for processing (5)
  • CLAUDE.md
  • docs/quickstart.md
  • internal/config/config.go
  • internal/config/config_test.go
  • render.yaml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 9, 2026

@aaronbrethorst aaronbrethorst merged commit 74431bd into main May 9, 2026
7 checks passed
@aaronbrethorst aaronbrethorst deleted the fixes branch May 9, 2026 22:00
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