containers / containers/podman-py
ServiceConnection.identity raises TypeError when a connection has no identity
- Dominant language
- Python
- Stars
- 381
- Forks
- 140
- Avg merge
- 5h 30m
- Merged PRs (30d)
- 1
Description
### Summary
`ServiceConnection.identity` raises `TypeError` for any connection that has no identity configured — every `unix://` connection, and any `ssh://` connection added without `--identity`.
### Code (current `main`)
```python
@cached_property
def identity(self):
"""Path: Returns Path to identity file for service connection."""
if self.attrs.get("identity"):
return Path(self.attrs.get("identity"))
return Path(self.attrs.get("Identity"))
```
When neither key is present this is `Path(None)`.
### Reproducer
Any host with a local `unix://` connection in `podman system connection list`:
```python
from podman.domain.config import PodmanConfig
cfg = PodmanConfig()
for name, svc in cfg.services.items():
print(name, svc.identity)
```
```
TypeError: argument should be a str or an os.PathLike object where
__fspath__ returns a str, not 'NoneType'
```
Merely enumerating the configured connections is enough to hit it — the caller does not have to be doing anything unusual.
Same result with a hand-written `containers.conf` containing an ssh destination with no `identity =` line, so it is not specific to unix sockets.
### Expected
`identity` returns `None` when no identity is configured, and callers treat it as optional.
### Environment
podman-py 5.6.0 (Fedora `python3-podman-5.6.0-4.fc44`), podman 5.8.4 client and server, rootless, Python 3.14. Code path re-checked against current `main` before filing.
### Note
This also breaks `PodmanClient(connection=...)`; filed separately since the fix there is different.
Contributor guide
Research direction
Start at ServiceConnection.identity in podman.domain.config and reproduce the failure by enumerating PodmanConfig().services for a connection without an identity. The work is done when identity is optional and returns None for unix:// or identity-less ssh:// connections, without raising during enumeration; add or update the relevant regression test if the repository provides one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100