containers / containers/podman-py
PodmanClient(connection=...) unusable without an identity; explicit identity= is ignored
- 主要言語
- Python
- スター
- 381
- フォーク
- 140
- 平均マージ
- 5時間 30分
- マージ済み PR(30日)
- 1
説明
### 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.
コントリビューションガイド
調査の方向性
client.py から始め、api_kwargs の構築時に PodmanClient が connection と active_service のパスをどのように処理するかを調べます。issue にある 3 つの呼び出しを再現し、そのうえで明示的な identity が尊重され、identity のない接続では例外を発生させずに引数が省略されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 活発
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 78/100