JoshStern / push-md-to-notion

Push Markdown to Notion
7 stars 4 forks source link

body failed validation: body.children.length should be ≤ `100`, instead was `124` #3

Open akrulec opened 1 week ago

akrulec commented 1 week ago

I have recently started seeing the following error with every push. Any idea what it refers to? Thank you

@notionhq/client warn: request fail {
  code: 'validation_error',
  message: 'body failed validation: body.children.length should be ≤ `100`, instead was `124`.'
}
Failed to push markdown file RetryError: Failed after 2 attepts
    at retry (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:42486:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async pushUpdatedMarkdownFiles (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:42494:17)
    at async main (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:42554:5) {
  failures: [
    APIResponseError: body failed validation: body.children.length should be ≤ `100`, instead was `124`.
        at buildRequestError (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:23059:16)
        at _Client.request (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:26765:50)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async NotionApi.appendMarkdown (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:42406:5)
        at async pushMarkdownFile (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:425[29](https://github.com/trainwell/android-client/actions/runs/10889475070/job/30216198578#step:3:30):3)
        at async retry (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:42471:19)
        at async pushUpdatedMarkdownFiles (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:42494:17)
        at async main (/home/runner/work/_actions/JoshStern/push-md-to-notion/v0.3.0/dist/main.js:42554:5) {
      code: 'validation_error',
      status: 400,
      headers: [_Headers [Headers]],
      body: '{"object":"error","status":400,"code":"validation_error","message":"body failed validation: body.children.length should be ≤ `100`, instead was `124`.","request_id":"142d84e9-f173-4f84-a682-e1549d4a72d7"}'
    },
JoshStern commented 5 days ago

Looks like an issue with this function: https://github.com/JoshStern/push-md-to-notion/blob/8868a8e5e0f431adb368812155cf5fc8c9fbfa25/src/notion.ts#L46

My bet is your doc gets parsed to more than 100 blocks which is the API limit for Notion. We can iterate over batches of 100 instead of trying to append blocks all at once.

It'll be a while for me to get to something like this but I'm around to review if you want to contribute.