Daanoz / ha-google-photos

Home Assistant Google Photos integration
MIT License
87 stars 7 forks source link

Fails on Selecting Album #17

Closed darrynlowe closed 1 year ago

darrynlowe commented 1 year ago

Version of the custom_component

0.4.4

Describe the bug

After CONFIGURE, and SELECT ALBUM, it spins for a second and then says "Error".

P.S. Thanks for the integration - it's great, and much cleaner than the brutal hack I was doing before.

Apr 01 17:01:23 archlinux hass[626391]: 2023-04-01 17:01:23.357 ERROR (MainThread) [aiohttp.server] Error handling request
Apr 01 17:01:23 archlinux hass[626391]: Traceback (most recent call last):
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
Apr 01 17:01:23 archlinux hass[626391]:     resp = await request_handler(request)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
Apr 01 17:01:23 archlinux hass[626391]:     resp = await handler(request)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
Apr 01 17:01:23 archlinux hass[626391]:     return await handler(request)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/security_filter.py", line 67, in security_filter_middleware
Apr 01 17:01:23 archlinux hass[626391]:     return await handler(request)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
Apr 01 17:01:23 archlinux hass[626391]:     return await handler(request)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
Apr 01 17:01:23 archlinux hass[626391]:     return await handler(request)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/ban.py", line 80, in ban_middleware
Apr 01 17:01:23 archlinux hass[626391]:     return await handler(request)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/auth.py", line 234, in auth_middleware
Apr 01 17:01:23 archlinux hass[626391]:     return await handler(request)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/view.py", line 146, in handle
Apr 01 17:01:23 archlinux hass[626391]:     result = await result
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/config/config_entries.py", line 241, in post
Apr 01 17:01:23 archlinux hass[626391]:     return await super().post(request, flow_id)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/data_validator.py", line 72, in wrapper
Apr 01 17:01:23 archlinux hass[626391]:     result = await method(view, request, data, *args, **kwargs)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/data_entry_flow.py", line 110, in post
Apr 01 17:01:23 archlinux hass[626391]:     result = await self._flow_mgr.async_configure(flow_id, data)
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 267, in async_configure
Apr 01 17:01:23 archlinux hass[626391]:     result = await self._async_handle_step(
Apr 01 17:01:23 archlinux hass[626391]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
Apr 01 17:01:23 archlinux hass[626391]:     result: FlowResult = await getattr(flow, method)(user_input)
Apr 01 17:01:23 archlinux hass[626391]:   File "/home/hassio/.homeassistant/custom_components/google_photos/config_flow.py", line 192, in async_step_albumselect
Apr 01 17:01:23 archlinux hass[626391]:     data_schema = await self._get_albumselect_schema()
Apr 01 17:01:23 archlinux hass[626391]:   File "/home/hassio/.homeassistant/custom_components/google_photos/config_flow.py", line 163, in _get_albumselect_schema
Apr 01 17:01:23 archlinux hass[626391]:     album["title"], album["mediaItemsCount"]
Apr 01 17:01:23 archlinux hass[626391]: KeyError: 'mediaItemsCount'
Daanoz commented 1 year ago

Looks like the same issue as #4. Somehow in some cases the Google Api returns partial data. Should be easy fixable.

Daanoz commented 1 year ago

Please give v0.5.0 a try. There should be an entry in your albums list that has (? items) behind album name, if possible I would like to hear back what type of album that is, maybe some special album? It would help me to figure out what is causing these issues.

darrynlowe commented 1 year ago

Installed 0.5.0 and it seems quite happy now - thank you!

There were four albums that had a ? after them (out of about 100 albums). Nothing special in those albums with the question mark (i.e., the ones that had the correct count had up to 20,000 photos in them and worked fine when selected).

In any event, it seems to be working well now.