Skip to content

Conversation

@jheddings
Copy link
Contributor

@jheddings jheddings commented Feb 3, 2021

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

@jheddings jheddings changed the title Skip empty records in map #269 Skip empty records in map Feb 3, 2021
@julrach
Copy link

julrach commented Feb 4, 2021

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
Copy link
Contributor Author

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.

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.

Copy link

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 💯

Copy link
Contributor Author

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?

Copy link

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 :)

Copy link
Contributor Author

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 😄

Copy link

@ttran ttran Feb 4, 2021

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

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!

@jamalex
Copy link
Owner

jamalex commented Feb 5, 2021

Thanks for the prompt fix on this, @jheddings! Appreciate the contribution. I'll be cutting a new release tonight with this in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants