jamalex / jamalex/notion-py

Internal Server Error -> Space that has CRDT enabled should have crdt

Open
#405 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.4k
Forks
470
PR merge metrics
No merged PRs in 30d

Description

What’s happening

Calling collection.add_row() is blowing up with a 500 from /api/v3/submitTransaction.

requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://www.notion.so/api/v3/submitTransaction

Raw response:

{
  "errorId": "07f2cd70-71ec-422e-9b41-4706f4d5a240",
  "name": "CrdtAssertionError",
  "clientData": {
    "type": "unsaved_transactions",
    "errors": [
      {
        "id": "f71a385f-645f-4ad0-9412-78c0394920a1",
        "name": "CrdtAssertionError",
        "retryable": false
      }
    ],
    "untried": []
  },
  "debugMessage": "Unsaved transactions: Space that has CRDT enabled should have crdt blocks",
  "message": "Something went wrong. (500)"
}
Code
from notion.client import NotionClient
from dotenv import load_dotenv
import os

load_dotenv()

client = NotionClient(token_v2=os.getenv("NOTION_TOKEN_A"))

cv_page = client.get_block(os.getenv("NOTION_URL_A"))  # DB page URL
cv = cv_page.collection

row = cv.add_row()
row.title = "Just some data"
What I found

The create_record() method builds an args dict for the set operation but it doesn’t include space_id.
When I add that field, Notion happily generates the CRDT metadata and the call succeeds.

Patch (in client.py, ~line 370):

args = {
    "id": record_id,
    "version": 1,
    "alive": True,
    "created_by_id": self.current_user.id,
    "created_by_table": "notion_user",
    "created_time": now(),
    "parent_id": parent.id,
    "parent_table": parent._table,
    "crdt_format_version": 1,
    "space_id": self.current_space.id,          # ← missing
    "crdt_data": { ... }
}

Does that fix line up with what you’re seeing?
If you can reproduce the 500 and this one-liner solves it, I can send a PR. Let me know what you think!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in client.py around line 370, where create_record() builds the set-operation args for collection.add_row(). Reproduce the provided call against /api/v3/submitTransaction and verify that the missing space_id is included and the request no longer returns the reported CrdtAssertionError 500.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.