Fix "Invalid handler specified" error on initial config flow setup#7
Draft
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
AI
changed the title
[WIP] Fix error at initial setup
Fix "Invalid handler specified" error on initial config flow setup
Mar 17, 2026
Owner
|
@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>
Contributor
Author
Reverted the previous incorrect fix. The real error (from the HA logs) was Fixed in cc4a319 by removing the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.existswithos.path.existsfor key file validation.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.