Bad Request from supervisor should be error #111162
Merged
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.
Proposed change
If an API call is made to Supervisor and it cannot process it due to invalid input or a handled issue that occurred with the particular resource it responds with a 400 (Bad Request) type response. This is an error, the API call was not processed successfully. Core should treat it like an error and raise an exception like it would or any other non-200 type response.
Currently this causes a number of problems. For example, repairs created by supervisor always disappear when the user applies the repair even if it wasn't actually applied successfully. Or when a service call results in an API call to supervisor with invalid input but appears to have been processed successfully:
I'm not entirely sure why Bad Request was originally given a pass on raising an exception so I don't know exactly what issues this change could cause. Hopefully if someone does they can comment and we can work on those. Logically though it doesn't really make sense to me, a 400 response is clearly an error and should not be treated like a success.
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: