Fix jsonpath namespace collision by vendoring the full jsonpath engine - #324
Open
HenkSnavel wants to merge 2 commits into
Open
Fix jsonpath namespace collision by vendoring the full jsonpath engine#324HenkSnavel wants to merge 2 commits into
HenkSnavel wants to merge 2 commits into
Conversation
`from jsonpath import jsonpath` resolves to a module instead of the callable when `jsonpath-python` is installed (pulled in transitively by Home Assistant core 2026.7 / Python 3.14), raising `TypeError: 'module' object is not callable` and breaking all data fetching. The config flow then fails with a generic "Unexpected error" and the integration cannot be added; when it does load, only the few non-filter sensors populate. PyPI `jsonpath` (0.82) and `jsonpath-python` both own the top-level `jsonpath` import name and cannot coexist. A simple dotted-path replacement is not enough because endpoint paths rely on filter expressions such as `production[?(@.type=='inverters' && @.activeCount > 0)].wNow`. Vendor the full Goessner `jsonpath` 0.82 engine (MIT) in-tree and drop the `jsonpath` requirement from the manifest. The vendored copy was behaviour-tested 1:1 against the original package across every filter expression the integration uses, so all existing path strings work unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
|
I would suggest putting the vendored jsonpath in a separate file and include that one. then we keep it separate from code we maintain ourselves. Other than that, great suggestion and thanks! |
Per review feedback, keep the vendored Goessner jsonpath engine in a separate file (jsonpath_vendor.py) so it stays isolated from code we maintain ourselves. envoy_reader now imports it with `from .jsonpath_vendor import jsonpath`. No behaviour change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
Done — moved the vendored engine into its own |
Owner
|
I will first look into just using the library that Home Assistant nowadays imports. At first glance that should not be a problem. As an alternative we can use the solution proposed here. Thanks. |
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 Home Assistant core 2026.7 (Python 3.14) the integration fails to set up: the
config flow shows a generic "Unexpected error", and even when an entry loads,
only the handful of non-filter sensors get values.
Root cause is a Python import-name collision:
jsonpath-pythonis now pulled in transitively by HA core, and it owns the sametop-level
jsonpathimport name as the PyPIjsonpath(0.82) package thisintegration requires.
from jsonpath import jsonpaththen resolves to a moduleinstead of the callable. The two packages cannot coexist.
Why not a small dotted-path shim
A minimal
key.key[0]resolver is not sufficient — the endpoint paths rely onfilter expressions, e.g.:
These need the real engine's
[?(...)]filtering and flattening semantics.Fix
Vendor the full Goessner
jsonpath0.82 engine (MIT licensed) in-tree asnormalize()+jsonpath(), and dropjsonpathfrommanifest.jsonrequirements. No external dependency, no name collision.
The vendored copy was behaviour-tested 1:1 against the original
jsonpath0.82.2 package across every filter expression the integration uses, so all
existing path strings keep working unchanged.
Notes
all 44 sensors populate correctly after the change.
parser that does not evaluate the
[?(...)]filter expressions, leaving mostsensors empty.