Skip to content

fix(python): measure Unix socket paths in filesystem bytes - #3007

Merged
inureyes merged 2 commits into
lablup:mainfrom
Jaeyeong-CHOI:fix/python-uds-path-byte-length
Nov 14, 2026
Merged

inureyes merged 2 commits into
lablup:mainfrom
Jaeyeong-CHOI:fix/python-uds-path-byte-length

Conversation

@Jaeyeong-CHOI

Copy link
Copy Markdown
Contributor

Summary

The Python client's early check on the Unix socket path length counted characters where the limit is in bytes, so a non-ASCII path over 100 bytes was accepted and left to fail at bind time. The check now measures len(os.fsencode(path)) and reports that number.

Related issues

Closes #3006.

Type of change

  • fix — bug fix

Cause

The Unix-socket branch of ManagedServer.__init__ (python/src/mlxcel/_server.py) compared len(path) with _MAX_SOCKET_PATH. A path of 35 Hangul characters under /tmp is 63 characters and 133 bytes: it passed the check, and a bind to it fails with AF_UNIX path too long.

Change

  • The check uses the encoded length, len(os.fsencode(path)), and the error message prints it. The 100-byte limit itself is unchanged.
  • python/tests/test_lifecycle.py: test_unicode_socket_path_rejected_before_start (101 and 133 bytes, each through ManagedServer, LLM and AsyncLLM; start() is patched to fail the test if it is reached) and test_socket_path_at_byte_limit_serves_requests (an ASCII and a Hangul path of exactly 100 bytes, each serving one request over the socket through the suite's fake server).

Before / after

Linux aarch64, Python 3.12.3, paths in a temporary directory.

main This PR
the eight new cases 6 failed (every over-limit path accepted), 2 passed (the 100-byte controls) 8 passed
63-character / 133-byte path accepted; a bind to it fails with AF_UNIX path too long MlxcelServerError: Unix socket path is too long (133 > 100 bytes)
whole suite (-m "not e2e"), openai 3.49.0 / httpx 0.28.1 59 passed, 2 deselected
whole suite, openai 1.40.0 / httpx 0.27.0 59 passed, 2 deselected

Test plan

Run on this PR's source (one commit on 955335a38, tree e78a8bba8f5e).

  • python -m pytest -m "not e2e" in python/: 59 passed, 2 deselected, with the declared lower bounds and with current releases
  • The new cases on main: 6 failed, 2 passed
  • ruff check python, ruff format --check python, mypy python/src: pass
  • Together with five other Python client fixes proposed separately, on Python 3.12.3 and 3.9.25 with the declared lower bounds (openai 1.40.0 / httpx 0.27.0) and with current releases: 101 passed, 2 deselected in each of the four environments. This PR on its own was run on 3.12 only
  • The two live-model e2e tests: not run
  • Rust gates: not applicable, no Rust file changes
  • Windows and macOS: not run (the new tests skip on Windows, where the client uses TCP)

Notes for reviewers

  • Scope. Only the length measurement. What happens to an existing file at the socket path is not touched here.
  • A path between 101 and 107 bytes is accepted by Linux itself; it is rejected here because the client's own limit is 100 bytes (headroom for the 104-byte macOS limit), as it already was for ASCII paths.
  • Implemented and validated with AI assistance (Claude). Every number above comes from the logs of those runs.

Checklist

  • PR title uses a Conventional Commits prefix
  • One logical change per PR
  • Updated docs/: not needed
  • Updated // Used by: ... comments: not applicable (Python)
  • No secrets, credentials, or .env files committed

The early check on the managed server's Unix socket path compared
`len(path)`, a character count, with the 100-byte limit. A path with
non-ASCII characters could exceed the limit and still pass, leaving the
failure to the child's bind; the error message also printed the character
count as bytes.

Measure `len(os.fsencode(path))` and report that length. The limit itself
is unchanged.
@inureyes

Copy link
Copy Markdown
Member

Thanks for catching this. Reviewed against #3006: the length check now counts os.fsencode(path) bytes, which is what sun_path limits, the message reports that byte count, and the 100-byte limit is unchanged. The byte-limit test serving a request over a 100-byte Hangul path is a good guard. No security or performance concerns.

I merged current main into the branch (no conflicts) and reran locally on macOS: 112 passed, 2 deselected on Python 3.11 and 3.9; ruff and mypy clean. No further changes were needed. The test (Python 3.9) CI job fails only in setup-python (tracked by #3013).

@inureyes
inureyes merged commit 1291a02 into lablup:main Nov 14, 2026
34 of 35 checks passed
@inureyes inureyes added the status:done Completed label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:done Completed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(python): Unix socket path length limit is checked in characters, not bytes

2 participants