allow extra
This commit is contained in:
parent
550637a125
commit
85d9ec36b3
2 changed files with 5 additions and 12 deletions
|
@ -221,12 +221,7 @@ class ActiveConnection:
|
|||
handler, schema = handler_schema
|
||||
|
||||
try:
|
||||
if schema is False:
|
||||
if len(msg) > 2:
|
||||
raise vol.Invalid("Message has unexpected keys")
|
||||
handler(self.hass, self, msg)
|
||||
else:
|
||||
handler(self.hass, self, schema(msg))
|
||||
handler(self.hass, self, msg if schema is False else schema(msg))
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
self.async_handle_exception(msg, err)
|
||||
|
||||
|
|
|
@ -130,14 +130,12 @@ async def test_async_response_request_context(
|
|||
}
|
||||
)
|
||||
|
||||
# Extra keys in message are allowed and ignored
|
||||
# to match the default of ALLOW_EXTRA
|
||||
msg = await websocket_client.receive_json()
|
||||
assert msg["id"] == 10
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == "invalid_format"
|
||||
assert msg["error"]["message"] == (
|
||||
"Message has unexpected keys. "
|
||||
"Got {'id': 10, 'type': 'test-get-request', 'not_valid': 'dog'}"
|
||||
)
|
||||
assert msg["success"]
|
||||
assert msg["result"] == "/api/websocket"
|
||||
|
||||
|
||||
async def test_supervisor_only(hass: HomeAssistant, websocket_client) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue