Fix data fetch breaking on jsonpath namespace collision (TypeError: 'module' object is not callable) - #322
Closed
jelmerkk wants to merge 1 commit into
Closed
Conversation
The `jsonpath` PyPI package shares its top-level import name with `jsonpath-python`, which recent Home Assistant cores pull in transitively. When that package wins in the shared environment, `from jsonpath import jsonpath` resolves to a submodule instead of the callable, so every `jsonpath(...)` call raises `TypeError: 'module' object is not callable` in `_resolve_path` / `detect_model` and the coordinator fails with "Unexpected error fetching envoy ... data" — all entities go unavailable. Seen on HA 2026.7 beta. Drop the external `jsonpath` dependency and vendor a tiny resolver for the simple dotted key/index paths this integration actually uses (e.g. `channels[0].watts.now`). No wildcards, filters or recursion are used, so the behaviour is preserved (single-element list on match, False otherwise) while removing the dependency and the collision entirely. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Heads-up: this fixes the import-name collision, but the dotted-path parser here Only the simple non-filter paths populate. I hit exactly this on HA core 2026.7 Either way the requirement should be dropped from |
Owner
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.
Problem
On 2026.7b1 the integration stops fetching and all entities go unavailable, with the coordinator logging:
Root cause
manifest.jsonrequires thejsonpathPyPI package, andenvoy_reader.pydoesfrom jsonpath import jsonpathexpecting a callable. That import name is shared withjsonpath-python, which recent HA cores pull in transitively. Whenjsonpath-pythonwins the shared environment,from jsonpath import jsonpathresolves to a submodule instead of the function, so everyjsonpath(...)call raisesTypeError: 'module' object is not callable. It fails indetect_model()(endpoint_info.envoy_info.device.imeter), which runs for every model, so it affects metered and non-metered units alike.Fix
Drop the external
jsonpathdependency and vendor a tiny resolver. The integration only ever callsjsonpath()with simple dotted key/index paths (e.g.channels[0].watts.now,endpoint_info.envoy_info.device.imeter) — no wildcards, filters or recursion — so a ~15-line resolver fully preserves behaviour (single-element list on match,Falseotherwise) while removing the dependency, and the namespace collision, entirely.envoy_reader.py: removefrom jsonpath import jsonpath, add vendoredjsonpath()(both call sites unchanged).manifest.json: dropjsonpathfromrequirements.Testing
Applied to a live non-metered (Standard) Envoy on HA 2026.7 beta: the
TypeErroris gone, the coordinator fetches cleanly, andsensor.envoy_current_power_productionresumed reporting.python -m py_compilepasses.🤖 Generated with help from Claude Code