-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Improve failure handling and logging for invalid map responses #139681
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
Conversation
Hey there @Lash-L, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
try: | ||
parsed_map = parser.parse(map_bytes) | ||
except (IndexError, ValueError) as err: | ||
_LOGGER.debug("Exception when parsing map contents: %s", err) | ||
return None |
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.
So iirc the problem here is that map_bytes was getting passed in as None typically do to a timeout or some other issue that was causing issues. This is at the very least a good thing to do to help prevent errors
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.
My impression is that when map_bytes is None then we'd get a different error:
>>> a = None
>>> a[2]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not subscriptable
But we get an IndexError
:
>>> a[2]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: string index out of range
I think we already check for the empty string somewhere, so is it a single character getting returned? We'll see soon...
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.
Thanks, @allenporter 👍
../Frenck
Proposed change
Improve failure handling and logging for invalid map responses by catching exceptions and logging debug details about the image bytes.
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: