Skip to content

fix: work around asyncssh/fido2 AttributeError on Python 3.14 non-Windows#23

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-attributeerror-ctypes-hresult
Draft

fix: work around asyncssh/fido2 AttributeError on Python 3.14 non-Windows#23
Copilot wants to merge 3 commits intomainfrom
copilot/fix-attributeerror-ctypes-hresult

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

On Python 3.14, ctypes.HRESULT was removed for non-Windows platforms. When fido2 is installed in the HA environment, asyncssh's sk.py attempts from fido2.client.windows import WindowsClient inside a try/except ImportError block — but fido2/client/win_api.py raises AttributeError at module level (HRESULT = ctypes.HRESULT), which goes uncaught and blows up the entire asyncssh import.

Fix

Pre-attempt the problematic import in coordinator.py before asyncssh is loaded. On failure, write None into sys.modules["fido2.client.windows"] — Python's negative-cache mechanism — so that asyncssh's subsequent import attempt raises ImportError instead, which it already handles gracefully (disabling Windows WebAuthn support).

if sys.platform != "win32":
    try:
        import fido2.client.windows  # noqa: F401
    except (ImportError, OSError, AttributeError) as _fido2_err:
        _LOGGER.debug(
            "fido2.client.windows unavailable (%s); asyncssh Windows WebAuthn support disabled",
            _fido2_err,
        )
        sys.modules["fido2.client.windows"] = None

This is a targeted workaround for a bug in asyncssh's exception handling (except ImportError should be except (ImportError, AttributeError)). No functional behaviour changes on Windows or in environments where fido2 is absent or fully compatible.

Copilot AI changed the title [WIP] Fix AttributeError in SSH Command integration on Python 3.14 fix: work around asyncssh/fido2 AttributeError on Python 3.14 non-Windows Apr 18, 2026
Copilot AI requested a review from gensyn April 18, 2026 20:33
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.

AttributeError: module 'ctypes' has no attribute 'HRESULT' on Python 3.14

2 participants