Silvenga / unifi-udm-api-proxy

A compatibility shim to support accessing the new UnifiOs API.
MIT License
11 stars 5 forks source link

'Response' object has no attribute 'status' on recording toggle #7

Closed mkgreco closed 4 years ago

mkgreco commented 4 years ago

Hi @Silvenga , I'm seeing a separate instance of the bug in #5 when I try to use the recording toggle - it's the exact same error, so maybe same root cause?

I grabbed a selection of the logs out of the docker container - I think the "warn" is related to this issue, as it doesn't occur at any other time.


Logger: homeassistant.components.websocket_api.http.connection.140355043906320 
Integration: websocket_api (documentation, issues) 
First occured: 9:01:29 AM (2 occurences) 
Last logged: 9:01:32 AM
'Response' object has no attribute 'status'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1230, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1253, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 198, in handle_service
    self._platforms.values(), func, call, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 402, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 590, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 433, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 623, in async_turn_off
    await self.hass.async_add_job(ft.partial(self.turn_off, **kwargs))
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/unifiprotect/switch.py", line 114, in turn_off
    self.data.set_camera_recording(self._camera_id, TYPE_RECORD_NEVER)
  File "/config/custom_components/unifiprotect/unifi_protect_server.py", line 334, in set_camera_recording
    % (response.status, response.reason)
AttributeError: 'Response' object has no attribute 'status'

---

info: UdmApi.Proxy.ProxyMiddleware[0]
      /api/events: Proxing request to 'GET https://10.0.1.1/proxy/protect/api/events?end=1583002266000&start=1583002246000&type=motion'.
info: UdmApi.Proxy.ProxyMiddleware[0]
      /api/events: Proxied with the result of '200'.
warn: UdmApi.Proxy.FallbackMiddleware[0]
      /cameras/5e531ad901a23303e7003e75: Failed to handle request, no handlers matched the request.
info: UdmApi.Proxy.ProxyMiddleware[0]
      /api/bootstrap: Handling request using 'UdmApi.Proxy.Services.ProtectProxy'.
info: UdmApi.Proxy.ProxyMiddleware[0]
      /api/bootstrap: Proxing request to 'GET https://10.0.1.1/proxy/protect/api/bootstrap'.
info: UdmApi.Proxy.ProxyMiddleware[0]
      /api/bootstrap: Proxied with the result of '200'.
info: UdmApi.Proxy.ProxyMiddleware[0]
      /api/events: Handling request using 'UdmApi.Proxy.Services.ProtectProxy'.
Silvenga commented 4 years ago

Thanks for the bug report. It looks like csrf tokens are breaking this endpoint. 😿 Should be a quick fix though.

Silvenga commented 4 years ago

Added in v1.3.0.