Skip to content

ServiceConnection.identity raises TypeError when a connection has no identity #652

Description

@michaelm-devel

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)

@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:

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions