Skip to content

Return None from ServiceConnection.identity when no identity is configured - #679

Closed
rjmcgee53192 wants to merge 1 commit into
containers:mainfrom
rjmcgee53192:contrib/fix-652
Closed

rjmcgee53192 wants to merge 1 commit into
containers:mainfrom
rjmcgee53192:contrib/fix-652

Conversation

@rjmcgee53192

Copy link
Copy Markdown
Contributor

Fixes #652

Problem

ServiceConnection.identity fell through to Path(self.attrs.get("Identity"))
when neither the identity (containers.conf) nor Identity
(podman-connections.json) key was present. That is Path(None), which raises:

TypeError: argument should be a str or an os.PathLike object where
__fspath__ returns a str, not 'NoneType'

So merely enumerating the configured connections crashed for every local
unix:// connection, and for any ssh:// connection added without
--identity.

Change

  • podman/domain/config.py: identity now returns None when no identity
    is configured, and a Path otherwise. Both key spellings keep working.
  • podman/client.py: the two call sites that read a connection's identity
    now leave the identity argument unset when the connection has none,
    instead of stringifying the value (which would have turned None into
    the literal string "None"). Behaviour is unchanged when an identity is
    configured or passed explicitly.

Tests

  • New PodmanConfigTestCaseNoIdentity in podman/tests/unit/test_config.py
    covers a unix:// connection and an ssh:// connection with no identity
    in podman-connections.json, including through active_service.
  • Full unit suite: 302 passed, 2 skipped (podman/tests/unit/test_utils.py
    excluded — it fails to collect on a machine without a podman binary,
    both before and after this change).
  • ruff check and ruff format --check pass on the touched files.

Accessing .identity on a connection without an identity file — every
unix:// connection, and ssh:// connections added without --identity —
fell through to Path(None) and raised TypeError, so simply enumerating
the configured connections crashed.

Return None instead, and leave the identity argument unset in
PodmanClient when a connection has none rather than passing the
string "None" to the SSH layer.

Fixes containers#652

Signed-off-by: rjmcgee53192 <[email protected]>
@Honny1

Honny1 commented Oct 20, 2026

Copy link
Copy Markdown
Member

Sorry, but there is already a PR that is fixing #652. Closing this in favor of #656

@rjmcgee53192 Please review #656

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ServiceConnection.identity raises TypeError when a connection has no identity

2 participants