Fix "Invalid handler specified" error on initial config flow setup#7
Fix "Invalid handler specified" error on initial config flow setup#7
Conversation
Move ConfigFlowResult import under TYPE_CHECKING to prevent ImportError on HA versions < 2024.4.0. Add minimum homeassistant version to manifest.json. Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
|
@copilot Revert those changes, they don't work. Then have another look at the issue, there is new information. |
The actual error was 'cannot import name wrap from aiofiles.base' because the aiofiles version in HA's Python 3.14 environment does not expose wrap from aiofiles.base. This causes an ImportError when loading __init__.py, preventing the config flow handler from being found. Remove aiofiles entirely and replace with: - os.path.exists() in __init__.py for key file validation - hass.async_add_executor_job(Path.exists/read_text) in coordinator.py Also reverts the incorrect ConfigFlowResult TYPE_CHECKING fix. Updates tests to patch os.path.exists and pathlib.Path.exists instead of the removed ssh_command.exists / ssh_command.coordinator.exists. Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Reverted the previous incorrect fix. The real error (from the HA logs) was Fixed in cc4a319 by removing the
|
|
@copilot In |
…ency Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com> Agent-Logs-Url: https://github.com/gensyn/ssh_command/sessions/6c179fe9-7f92-4a1e-9121-ce347e9ec33f
|
@copilot Please fix the integration tests that broke in this branch. |
…odule-level exists Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com> Agent-Logs-Url: https://github.com/gensyn/ssh_command/sessions/5e288baf-a5cc-4acb-bbee-ce3c6bf258ac
Fixed in b4624c3. The integration tests were patching module-level |
When loading the integration, HA's Python 3.14 environment raises
cannot import name 'wrap' from 'aiofiles.base'because the installed version ofaiofilesno longer exposeswrapfromaiofiles.base. ThisImportErroroccurs while loading__init__.py(which runs beforeconfig_flow.pycan be registered), so HA cannot find the config flow handler and returns "Invalid handler specified".Changes
__init__.py: Replaceaiofiles.ospath.existswithhass.async_add_executor_job(Path(...).exists)for key file validation — consistent with the HA-recommended pattern for non-blocking file I/O.coordinator.py: Removeaiofilesimports and replace async file operations withhass.async_add_executor_job(Path(...).exists)andhass.async_add_executor_job(Path(...).read_text)— the HA-recommended pattern for executor-based file I/O.manifest.json/requirements.txt: Remove theaiofiles==25.1.0requirement entirely, eliminating the version conflict with HA's bundledaiofiles.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.