watkins-matt / home-assistant-google-keep-sync

Custom component for Home Assistant that enables bidirectional synchronization with Google Keep lists.
MIT License
50 stars 4 forks source link

Error when authenticating #9

Closed Hassassistant closed 9 months ago

Hassassistant commented 9 months ago

When installing the integration I get the following error. Username and Token work as I tested it on a test Py script using gkeepapi and it pulled data just fine.

Logger: custom_components.google_keep_sync.config_flow
Source: custom_components/google_keep_sync/config_flow.py:182
Integration: Google Keep Sync ([documentation](https://github.com/watkins-matt/home-assistant-google-keep-sync))
First occurred: 17 January 2024 at 23:14:54 (13 occurrences)
Last logged: 09:54:13

Unexpected exception: Parse error in <class 'gkeepapi.node.WebLink'>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 214, in load
    self._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 291, in _load
    self._title = raw['webLink']['title']
                  ~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'title'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/google_keep_sync/config_flow.py", line 182, in async_step_user
    info = await self.validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/google_keep_sync/config_flow.py", line 167, in validate_input
    success = await self.api.authenticate()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/google_keep_sync/api.py", line 99, in authenticate
    if not await self.async_login_with_saved_token():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/google_keep_sync/api.py", line 66, in async_login_with_saved_token
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 722, in resume
    self.load(auth, state, sync)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 749, in load
    self.sync(True)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 1024, in sync
    self._sync_notes(resync)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 1074, in _sync_notes
    self._parseNodes(changes["nodes"])
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 1110, in _parseNodes
    node = _node.from_json(raw_node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 1930, in from_json
    node.load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 214, in load
    self._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 1191, in _load
    super(TopLevelNode, self)._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 1046, in _load
    self.annotations.load(raw['annotationsGroup'])
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 214, in load
    self._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 524, in _load
    annotation = self.from_json(raw_annotation)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 505, in from_json
    annotation.load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 214, in load
    self._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 450, in _load
    self._entries[key] = NodeAnnotations.from_json({key: entry})
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 505, in from_json
    annotation.load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 216, in load
    raise_from(exception.ParseException('Parse error in %s' % (type(self)), raw), e)
  File "/usr/local/lib/python3.11/site-packages/future/utils/__init__.py", line 406, in raise_from
    exec(execstr, myglobals, mylocals)
  File "<string>", line 1, in <module>
gkeepapi.exception.ParseException: Parse error in <class 'gkeepapi.node.WebLink'>
watkins-matt commented 9 months ago

I believe this is the same issue here https://github.com/kiwiz/gkeepapi/issues/155. It's an issue within gkeepapi.

It should be fixed in the next update as soon as we update to the newest version of gkeepapi.

FragMenthor commented 9 months ago

Yesterday I installed your integration, and everything went smootlhy, I could sync my list in HA. Today the integration stopped working, would not reload under any circumstances. Removed completly, reloaded, rebooted, created new mastertoken, and... nothing. I get this:

image

And the logs:

Este erro teve origem numa integração personalizada.

Logger: custom_components.google_keep_sync.config_flow
Source: custom_components/google_keep_sync/config_flow.py:182
Integration: Google Keep Sync (documentation)
First occurred: 14:53:51 (7 occurrences)
Last logged: 16:44:54

Unexpected exception: Parse error in <class 'gkeepapi.node.WebLink'>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 214, in load
    self._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 291, in _load
    self._title = raw['webLink']['title']
                  ~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'title'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/google_keep_sync/config_flow.py", line 182, in async_step_user
    info = await self.validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/google_keep_sync/config_flow.py", line 167, in validate_input
    success = await self.api.authenticate()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/google_keep_sync/api.py", line 98, in authenticate
    if not await self.async_login_with_saved_state():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/google_keep_sync/api.py", line 48, in async_login_with_saved_state
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 722, in resume
    self.load(auth, state, sync)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 749, in load
    self.sync(True)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 1024, in sync
    self._sync_notes(resync)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 1074, in _sync_notes
    self._parseNodes(changes["nodes"])
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 1110, in _parseNodes
    node = _node.from_json(raw_node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 1930, in from_json
    node.load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 214, in load
    self._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 1191, in _load
    super(TopLevelNode, self)._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 1046, in _load
    self.annotations.load(raw['annotationsGroup'])
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 214, in load
    self._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 524, in _load
    annotation = self.from_json(raw_annotation)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 505, in from_json
    annotation.load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 214, in load
    self._load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 450, in _load
    self._entries[key] = NodeAnnotations.from_json({key: entry})
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 505, in from_json
    annotation.load(raw)
  File "/usr/local/lib/python3.11/site-packages/gkeepapi/node.py", line 216, in load
    raise_from(exception.ParseException('Parse error in %s' % (type(self)), raw), e)
  File "/usr/local/lib/python3.11/site-packages/future/utils/__init__.py", line 406, in raise_from
    exec(execstr, myglobals, mylocals)
  File "<string>", line 1, in <module>
gkeepapi.exception.ParseException: Parse error in <class 'gkeepapi.node.WebLink'>

Soooo.... what changed from yesterday to today??? That's what's bugging me... THANKS for your work!

watkins-matt commented 9 months ago

Yes, it appears to be the same issue. I think something may have changed on the Google Keep server side that started causing this issue.

I will try to push out an update soon that upgrades the version of gkeepapi that the integration uses. It should fix the issue; I just need to do some testing to make sure it doesn't break anything else.

watkins-matt commented 9 months ago

Please update to the latest version 0.9.2. It should fix this issue.

FragMenthor commented 9 months ago

Please update to the latest version 0.9.2. It should fix this issue.

Thanks you! It... WOOOORKSSS :)