Bug
_OsBackend.stat() in etils/epath/backend.py crashes with KeyError when a file is owned by a UID/GID not present in /etc/passwd or /etc/group.
This is common in:
- Container environments where the host UID doesn't exist inside the container
- Shared/network filesystems (NFS, FUSE) where files are owned by remote UIDs
Reproduction
# In a container where files are owned by UID 1000 but /etc/passwd has no entry for it:
from etils import epath
p = epath.Path("/some/file/owned/by/unknown/uid")
p.stat() # KeyError: 'getpwuid(): uid not found: 1000'
Traceback
File "etils/epath/gpath.py", line 293, in stat
return self._backend.stat(self._path_str)
File "etils/epath/backend.py", line 235, in stat
owner = pwd.getpwuid(st.st_uid).pw_name
KeyError: 'getpwuid(): uid not found: 1000'
Impact
Downstream libraries like orbax-checkpoint call epath.Path.stat() during checkpoint loading, causing crashes that are difficult to work around.
Suggested fix
Catch KeyError and fall back to the numeric UID/GID as a string, consistent with how ls -n handles unknown UIDs.
See PR #789.
Bug
_OsBackend.stat()inetils/epath/backend.pycrashes withKeyErrorwhen a file is owned by a UID/GID not present in/etc/passwdor/etc/group.This is common in:
Reproduction
Traceback
Impact
Downstream libraries like
orbax-checkpointcallepath.Path.stat()during checkpoint loading, causing crashes that are difficult to work around.Suggested fix
Catch
KeyErrorand fall back to the numeric UID/GID as a string, consistent with howls -nhandles unknown UIDs.See PR #789.