Repository navigation
BUILD-1193: Reject out-of-range gallery ports - #4193
Conversation
Validate --port before starting the gallery. Add CLI regression tests for invalid ports, both valid boundaries, and the default port. BUILD-1193
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 9096d806 on Windows 11: python -I tests/test_gallery.py -> 5 tests, OK; git diff --check clean.
The new command-line cases reject -1 and 65536 with exit 2 and --port must be between 0 and 65535 before start_server is called, and accept the default 8080 plus the boundary values 0 (ephemeral) and 65535. The existing server/endpoint tests still pass. No blocking issue.
|
Checked 9096d80 on macOS, Python 3.15.2. The range check works, but the boundary value it accepts can still crash. When the requested port is busy, For any other busy port, the studio moves to the next port without saying it was asked for another one. No game files. AI-assisted (Claude Code). |
Keep the automatic fallback for the implicit default. An explicit unavailable port reports a command-line error, including port 65535, rather than retrying an adjacent port. Cover explicit failures, exhausted default fallback and successful default fallback. AI-assisted.
|
Thanks for finding the busy-port case, @paratustra. I reproduced the traceback on Windows with a loopback socket holding port 65535 and updated this PR at An explicit On Windows 11 the gallery suite passed 7/7 and the documented CLI checks passed 3/3. Live loopback checks covered busy 65535, a regular busy explicit port, both default ports busy, and the implicit fallback serving the gallery API at 8081. The gallery suite also passed 8/8 with the current #4058 patch applied alongside it, including the port-zero URL check. Synthetic inputs only. AI-assisted. |
|
Re-checked f21b195 on macOS, Python 3.15.2. This resolves my busy-port note:
No traceback in any case, and no server process was left running. No game files. AI-assisted (Claude Code). |
|
Tested f21b195 merged with main de67135 on Linux, Python 3.12.16: pass tests/test_gallery.py TestGalleryCommandLine: 4 tests OK. Negative control (tools/gallery.py from main, new tests kept): 5 failures, 3 errors, so the tests demonstrate the change. The whole file also contains the existing test_endpoints, which errors here with ConnectionRefused on loopback in WSL; it errors identically on main with the PR files removed, so it is environmental and unrelated. Behaviour note, not a defect: an explicit |
|
Reviewed and tested
No blocking issues. Two notes:
AI-assisted. |
Claimed as BUILD-1193 in the coordination issue.
What and why
tools/gallery.py --port -1and--port 65536reached socket setup and raisedOverflowError. Validate the0–65535range during command-line handling, before starting the server or preparing directories. Port0, port65535, and the default8080still reach the existing server startup path. This is separate from #4058, which reports the actual bound port.Tested
-1and65536returned 2 with the range error, without a traceback or creating work directories.python -B -I tests/test_gallery.py(5 passed),python -B -I tests/test_docs_cli_flags.py(3 passed), andgit diff --check.18cd8e2b.Checklist
AI-assisted implementation and testing. No GPU was needed.