feat(cli): add --port-base to shift port-probe range - #635
Open
finklang wants to merge 2 commits into
Open
Conversation
added 2 commits
July 16, 2026 13:53
Adds three layers of override for the port probe's start port so users
can dodge collisions with other local dev servers (Apollo BE on 8090,
etc.) without editing source:
1. --port-base PORT CLI arg (per-invocation)
2. CODE_PUPPY_PORT_BASE env var (per-shell)
3. port_base key in puppy.cfg (persistent, seeded on first run)
Precedence: CLI > env > puppy.cfg > 8090 default. All three sources
funnel through resolve_port_base() + _coerce_port_base() for DRY
validation with a consistent warning UX.
Robustness:
* CLI arg is type=str so bad input is caught by our validator and
falls through to the next source rather than argparse-exiting.
* MIN_PORT_BASE=1024 / MAX_PORT_BASE=65535-PORT_PROBE_WIDTH reject
values that would probe outside the 16-bit port range or hit
privileged ports the process can't bind anyway.
* ensure_config_exists() seeds port_base in fresh puppy.cfg so
users discover the knob (matches the existing auto_save_session
seeding pattern).
Tests: 13 new tests across TestGetPortBase, TestResolvePortBase, and
TestPortAvailability covering precedence, bounds, graceful fallback,
empty-string handling, exact boundaries, config seeding, and a
regression guard on MAX_PORT_BASE + PORT_PROBE_WIDTH <= 65535.
Upstream introduced code_puppy.i18n (t/ngettext) after this branch was
cut and will want the 'no available ports' error message routed through
the translation layer. Rather than hardcode 8090-9010 in the locale
string (which would lie to anyone using --port-base to shift the probe
range), the message is parameterized on {port_base}/{port_end} and the
call site passes both.
Localizations for other languages fall back to en-US per the existing
i18n resolution chain; contributors can override per-locale later.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds three layers of override for the port probe's start port so users can dodge collisions with other local dev servers (Apollo BE on 8090, etc.) without editing source:
Precedence: CLI > env > puppy.cfg > 8090 default. All three sources funnel through resolve_port_base() + _coerce_port_base() for DRY validation with a consistent warning UX.
Robustness:
Tests: 13 new tests across TestGetPortBase, TestResolvePortBase, and TestPortAvailability covering precedence, bounds, graceful fallback, empty-string handling, exact boundaries, config seeding, and a regression guard on MAX_PORT_BASE + PORT_PROBE_WIDTH <= 65535.