-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Add message from Bad Request errors to HassioAPIError #113144
Conversation
Hey there @home-assistant/supervisor, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
It seems that the tests we have expects a json to be returned even when the error is Bad Request:
I guess this is to simulate the previous HTTP behavior? 🤔 |
Hm, on closer look This is actually not really what the Supervisor typically does, API errors always lead to a HTTP return status Bad Requuest (400):
So I think the tests needs fixing here and use HTTP status 400 instead. If |
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
With #111162 send_command() started to pass Bad Requests directly as Exception. Before that, errors got returned as dictionary, and ultimately converted into HassioAPIError in `websocket_supervisor_api` and and `api_data`. Raising HassioAPIError without adding the message lead to the frontend to show "Unknown error, see supervisor logs" in cases where the API actually returned a sensible message. It is generally a good idea to convert errors into exception as early as possible, so this PR still makes Bad Request raising an exception. However, with this change we add the message to the HassioAPIError exception object to restore previous behavior for websocket calls.
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
f248662
to
91dec1e
Compare
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, @agners 👍
../Frenck
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
…#113144) Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
Breaking change
Proposed change
With #111162 send_command() started to pass Bad Requests directly as Exception. Before that, errors got returned as dictionary, and ultimately converted into HassioAPIError in
websocket_supervisor_api
andapi_data
. Raising HassioAPIError without adding the message lead to the frontend to show "Unknown error, see supervisor logs" in cases where the API actually returned a sensible message.It is generally a good idea to convert errors into exception as early as possible, so this PR still makes Bad Request raising an exception. However, with this change we add the message to the HassioAPIError exception object to restore previous behavior for websocket calls.
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
..coveragerc
.To help with the load of incoming pull requests: