Fix `mk_maddr()` crash on absolute UDS paths

Strip leading `/` from `filepath` before building
the `/unix/{path}` multiaddr string; OW absolute
sockpaths like `/run/user/1000/tractor/foo.sock`
produce `/unix//run/..` which `py-multiaddr`
rejects as "empty protocol path".

Woops, missed this in the initial `mk_maddr()` impl
bc the unit tests only used relative `filedir` values
(which was even noted in a comment..). The bug only
surfaces when the `.maddr` property on `UDSTransport`
is hit during logging/repr with real runtime addrs.

Found-via: cross-suite `pytest tests/ipc/ tests/msg/`
where `tpt_proto='uds'` leaks into msg tests

(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
subint_spawner_backend
Gud Boi 2026-03-26 21:56:33 -04:00
parent 5c4438bacc
commit 5f6e45e1d4
1 changed files with 6 additions and 1 deletions

View File

@ -78,8 +78,13 @@ def mk_maddr(
case 'uds': case 'uds':
filedir, filename = addr.unwrap() filedir, filename = addr.unwrap()
filepath = Path(filedir) / filename filepath = Path(filedir) / filename
# NOTE, strip any leading `/` to avoid
# double-slash `/unix//run/..` which the
# multiaddr parser rejects as "empty
# protocol path".
fpath_str: str = str(filepath).lstrip('/')
return Multiaddr( return Multiaddr(
f'/{maddr_proto}/{filepath}' f'/{maddr_proto}/{fpath_str}'
) )