-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed logic to handle invalid JSON and return an empty dictionary #134010
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR description is missing the proposed change and what is trying to be fixed here.
There was an issue (#133289) indicating that the JSON result was neither a dictionary nor a list, with the first element not being a dictionary. I modified the logic a bit to handle invalid JSON. |
I don't get all the changes here since the only thing really done is to change the logging from Secondly it's lacking the argumentation why we should do this change and not warn when it's actually returning an incorrect json? |
The main change here improves the logic to handle cases where json_dict is unexpected, like a list without a dictionary as the first element. The previous version could raise runtime errors or log incorrect warnings. The logging level was changed to debug to reduce noise for non-critical issues. If this should remain a warning, I can adjust it. If I misunderstood the problem or if something here is incorrect, please let me know! |
That's the thing right, because if you are here, then a I suppose in your case what you want to achieve is to mute the logging when the json path is empty (or something as such)? Converted the PR to draft while we are discussing. |
Breaking change
Proposed change
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: