Commit c3b771c
`--port` was a string flag whose only consumer was a bare `parseInt`, so
`--port abc` became `NaN`, travelled the whole port policy untouched, and
reached the real `listen()` — which refused it at the socket layer with
`ERR_SOCKET_BAD_PORT: options.port should be >= 0 and < 65536`. The operator
mistyped a flag and got back an error naming an internal option, from a code
path with no connection to the thing they typed. `--port 99999` died the same
way, and `PORT=abc` / `OS_PORT=abc` are the same defect through another door.
The value is now checked at the point all three inputs converge, before the
port-conflict policy and before any socket exists. The refusal names which
input was used, and states the range by interpolating the bounds the code
enforces rather than a second hand-written copy of them.
The bounds are measured, not copied: `listen(0)` binds a kernel-assigned port,
so 0 is accepted; the ceiling is 65535, one less than the `< 65536` the
kernel's own message names.
`Flags.integer({ min, max })` was measured and not taken. oclif never runs a
flag's parser over a `default`, and `PORT`/`OS_PORT` arrive through the default
— so an integer flag would have guarded `--port` alone and left two of the
three reported paths dying exactly as before. It would also have narrowed what
boots: its `/^-?\d+$/` refuses `" 3000"`, `"3000.0"`, `"0x0BB8"`, `"+3000"`
and `"3e3"`, all of which boot today. `parseInt` therefore remains the reader
and only the refusal is added, so the accepted input set is unchanged.
Claude-Session: https://claude.ai/code/session_01UjujZN219uFzBhSYfMykCd
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1e4d2eb commit c3b771c
4 files changed
Lines changed: 651 additions & 8 deletions
File tree
- .changeset
- packages/cli/src/commands
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
171 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
172 | 175 | | |
173 | 176 | | |
174 | 177 | | |
| |||
0 commit comments