containers / containers/podman-py
PodmanClient(connection=...) unusable without an identity; explicit identity= is ignored
- Vorherrschende Sprache
- Python
- Sterne
- 381
- Forks
- 140
- Ø Merge
- 5 Std. 30 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
### Summary
`PodmanClient(connection=...)` cannot be used with a connection that has no identity, and passing an explicit `identity=` does **not** work around it, because the fallback is evaluated eagerly.
### Code (current `main`, `client.py`)
```python
api_kwargs["identity"] = kwargs.get("identity", str(connection.identity))
```
`str(connection.identity)` is a default *argument*, so Python evaluates it before `kwargs.get` runs — even when the caller supplied `identity`. With no identity configured, `connection.identity` is `Path(None)` and raises (see the separate report on `ServiceConnection.identity`).
The same pattern is used on the `active_service` path, so a bare `PodmanClient()` fails on a system whose active connection has no identity.
### Reproducer
```python
from podman import PodmanClient
PodmanClient(connection="remote-with-key") # OK
PodmanClient(connection="local") # TypeError
PodmanClient(connection="local", identity="/dev/null") # TypeError <-- explicit identity ignored
```
Measured against a host with a `unix://` connection named `local`.
### Expected
The explicit `identity=` is honoured, and a connection without one simply omits the argument.
### Suggested fix
Compute the fallback lazily:
```python
identity = kwargs.get("identity") or connection.attrs.get("Identity") or connection.attrs.get("identity")
if identity:
api_kwargs["identity"] = identity
```
### 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. Re-checked against current `main` before filing.
Beitragsleitfaden
Rechercherichtung
Start in client.py and inspect how PodmanClient handles the connection and active_service paths when building api_kwargs. Reproduce the three calls from the issue, then verify that explicit identity is honored and that connections without an identity omit the argument without raising.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Aktiv
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 78/100