question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError: "checked" when trying to sync new checkbox in list

See original GitHub issue

I’m getting a checkbox list from my Google Keep and assigning it to glist, adding a checked checkbox item and trying to sync. That code is:

glist = keep.get("*********")
glist.add('Item 3', True)
keep.sync()

I get the following error:

File "lib\site-packages\gkeepapi\node.py", line 1176, in load
self._checked = raw['checked']
KeyError: 'checked'

I poked around and it looks like when when line 559 in init.py is run, the variable “changes” is assigned with the checkbox not having a “checked” property. Here is line 559:

changes = self._keep_api.changes(
                target_version=self._version,
                nodes=[i.save() for i in self._findDirtyNodes()],
                labels=[i.save() for i in self._labels.values()] if labels_updated else None,
            )

if I stop right before that code is run and run the param snippet from above: nodes=[i.save() for i in self._findDirtyNodes()] you can see that the new ListItem has a property “checked = True”.

Stepping through line 559 in init.py takes you to line 269 in init.py, it’s the return for the self._keep_api.changes() function:

return self.send(
            url=self._base_url + 'changes',
            method='POST',
            json=params

The response you get from self.send() does not have the “checked” property anymore. It does have a “checked_ts_micro” property with a value of u'1521385638051000'. It looks like some measure of when the box was checked. If I run the original code with the checked param as False, glist.add('Item 3', False) ,that “checked_ts_micro” property has a value of u'0'.

This is as far as I gotten with investigating it. Not sure why it doesn’t return a “checked” property but it might be an easy fix to just add something like:

if: checked_ts_micro > 0:
    self.checked  = True
else:
    self.checked  = False

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kiwizcommented, Mar 26, 2018

@danielwossenu Finally managed to reproduce it. Hopefully the above change should fix the issue!

0reactions
newbebcommented, Apr 1, 2018

There is a bug in the load(self, raw) function in node.py where a string is getting loaded into _version and then comparison is failing due to “TypeError: unorderable types: str() > int()” on line 872 of node.py

The value of _version is loaded from the JSON as a str if the baseVersion is present

self._version = raw['baseVersion'] if 'baseVersion' in raw else self._version

Which throws the “TypeError: unorderable types: str() > int()” in the save function

if not self.moved and self._version > 0:

I’ll do a pull request shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Check Items for checkbox checked in Django - Stack Overflow
I am trying to create a html file that will display a form based on the records model. In the html file I...
Read more >
Python KeyError: A Beginner's Guide % - Career Karma
A KeyError is raised when you try to access a value from a dictionary that does not exist. To solve a key error,...
Read more >
How to fix Python KeyError Exceptions in simple steps?
First, we access an existing key in the try-except block. If the Keyerror is not raised, there are no errors. Then the else...
Read more >
Invalid key error, when clicking on a combobox from a nested ...
I ensured that the key value is unique. I tried adding the key value to c-filter-field and every other relevant tag(including inside the...
Read more >
Debugging errors - dbt Developer Hub
Failed to connect​. Encountered an error: Runtime Error Database error while listing schemas in database ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found