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
parent
5c4438bacc
commit
5f6e45e1d4
|
|
@ -78,8 +78,13 @@ def mk_maddr(
|
|||
case 'uds':
|
||||
filedir, filename = addr.unwrap()
|
||||
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(
|
||||
f'/{maddr_proto}/{filepath}'
|
||||
f'/{maddr_proto}/{fpath_str}'
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue