Skip to content

Inconsistent error while initializing the notion client #269

@yanmendes

Description

@yanmendes

I had a script that was working fine up until now and it just started breaking for some reason. Sometimes, when I'm initializing the notion client, I get the following error:

Initialization

notionClient = NotionClient(token_v2=os.environ.get('NOTION_TOKEN'))

Error

Traceback (most recent call last):
  File "/Users/<username>/.config/yarn/global/node_modules/serverless/lib/plugins/aws/invokeLocal/invoke.py", line 72, in <module>

    module = import_module(args.handler_path.replace('/', '.'))
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 783, in exec_module

  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./src/handlers/scrapeMentors.py", line 6, in <module>

    from ..services.notion import addMentorToNotion, updateMentorOnNotion, deleteRow
  File "./src/services/notion.py", line 4, in <module>

    notionClient = NotionClient(token_v2=os.environ.get('NOTION_TOKEN'))
  File "/Users/<username>/Library/Python/3.8/lib/python/site-packages/notion/client.py", line 68, in __init__

    self._update_user_info()
  File "/Users/<username>/Library/Python/3.8/lib/python/site-packages/notion/client.py", line 75, in _update_user_info

    self._store.store_recordmap(records)
  File "/Users/<username>/Library/Python/3.8/lib/python/site-packages/notion/store.py", line 292, in store_recordmap

    for id, record in records.items():
AttributeError: 'NoneType' object has no attribute 'items'

Investigation

On store.py#L292, I noticed a table named __json__ that has None for records

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions