Skip to content

🐛 [BUG] - Cannot get page object if I do not have access to the parent database #103

@adamtheturtle

Description

@adamtheturtle

Problem description

I did not set up this integration, so I am not 100% sure what is going on.
I can investigate if this is not clear.

What I'm trying to do:

parent_page = session.get_page(page_ref="...")

What I am getting:

Traceback (most recent call last):
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/ultimate_notion/session.py", line 269, in get_page
    page = Page.wrap_obj_ref(self.api.pages.retrieve(page_uuid))
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/ultimate_notion/page.py", line 126, in wrap_obj_ref
    obj.props = obj._create_page_props_ns()
                ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/ultimate_notion/page.py", line 134, in _create_page_props_ns
    if self.parent_db is not None:
       ^^^^^^^^^^^^^^
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/ultimate_notion/page.py", line 181, in parent_db
    if is_db_guard(self.parent):
                   ^^^^^^^^^^^
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/ultimate_notion/core.py", line 143, in parent
    return session.get_db(db_ref=database_id)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/ultimate_notion/session.py", line 222, in get_db
    db = Database.wrap_obj_ref(self.api.databases.retrieve(db_uuid))
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/ultimate_notion/obj_api/endpoints.py", line 239, in retrieve
    data = self.raw_api.retrieve(str(db_id))
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/notion_client/api_endpoints.py", line 155, in retrieve
    return self.parent.request(
           ~~~~~~~~~~~~~~~~~~~^
        path=f"databases/{database_id}", method="GET", auth=kwargs.get("auth")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/notion_client/client.py", line 227, in request
    return self._parse_response(response)
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/adam/Documents/repositories/foobar/.venv/lib/python3.13/site-packages/notion_client/client.py", line 157, in _parse_response
    raise APIResponseError(response, body["message"], code)
notion_client.errors.APIResponseError: Could not find database with ID: XXXX. Make sure the relevant pages and databases are shared with your integration.

What I think is happening: to fill in various properties, the integration has to have access to the database.

What I'd hope for: I can get a Page object even without that database access - I want to do page-related things.

Expected behaviour

No response

Steps to reproduce

No response

Version

No response

Installation

No response

Python version

No response

Operating system

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions