- 
                Notifications
    You must be signed in to change notification settings 
- Fork 477
Skip empty records in map #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| heard that this was a fix to the #269 error so just thought i'd +1 this right here | 
|  | ||
| def store_recordmap(self, recordmap): | ||
| for table, records in recordmap.items(): | ||
| if records is None: continue | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appears to be a field (__json__) in the user content that is occasionally set to None.  This simply does a quick check and skips adding any empty record sets to the store.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work. But still, I'm uneasy as to why this is occurring right now or this is the prelude to major API changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha! This broke everything all at once for us 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to the change in this pull request or the bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to the change in this pull request or the bug?
The bug! Thank you for the fix :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing... It was a quick change, just making sure it didn't have some other consequences 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For folks wanting to monkey patch their code while waiting on the merge:
import notion
def store_recordmap(self, recordmap):
    for table, records in recordmap.items():
        if records is None: continue
        for id, record in records.items():
            self._update_record(
                table, id, value=record.get("value"), role=record.get("role")
            )
notion.store.RecordStore.store_recordmap = store_recordmap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to modify the first line in the above snippet to be import notion.store instead of import notion for it to work for me with python3.6 and notion==0.0.27.
thank you for the workaround until this gets merged!
| Thanks for the prompt fix on this, @jheddings! Appreciate the contribution. I'll be cutting a new release tonight with this in it. | 
I'm not sure if this is the best way to handle the error, but this seems to work around the problem I've been having today.
Workaround for #269