notion-py icon indicating copy to clipboard operation
notion-py copied to clipboard

client.get_block broken due to highest accepted "limit" value 100, but we use 100000

Open phoenixeliot opened this issue 4 years ago • 6 comments

I'm finding that using the client as it is now, with the "limit" set to 10000 when fetching a block, I get an HTTP error "invalid input".

https://github.com/jamalex/notion-py/blob/3533c012b421797ff0343ae955d37505b51500e8/notion/store.py#L280

By testing manually, I found that 100 is the highest value this will accept as of right now, and removes the error.

The library should be updated with the new limit here, and we might need new logic to paginate this request when the page has more than 100 blocks in it.

From a cursory glance it looks like there are other places with the number "10000" that may also need to be updated.

phoenixeliot avatar Mar 20 '21 23:03 phoenixeliot

It looks like the notion web client uses syncRecordValues to get the values of all the nodes after the first limit amount (the web client uses 30 for the limit). That network request sends back all the data for the specified block IDs, the list of which comes back in the initial loadPageChunk request (that this package uses now).

phoenixeliot avatar Mar 20 '21 23:03 phoenixeliot

@phoenixeliot Have you find the way to load/read more than 100 records?

miletoda avatar Jun 29 '21 15:06 miletoda

@miletoda You or I would need to write a patch/PR that implements the above suggestion. I might, but I don't have any use cases for 100+ block pages yet, so it's not super relevant to me personally yet. It should be quite doable, though, if you want to take a crack at it!

phoenixeliot avatar Jun 30 '21 20:06 phoenixeliot

To add more confirmation, this seems to be an issue with search_pages_with_parent as well. Manually lowering the limit param in the request succeeds. As of this comment client.current_space.pages seems to be throwing due to this issue.

edit: s/commit/comment

iansinnott avatar Aug 08 '21 07:08 iansinnott

This case is pretty relevant to me. I'd like to help, if I can.

The problem is, I'm not sure how the pagination works. Is there an example somewhere?

I'd also like to help fix monitoring, but that's unrelated to this issue. (Is there an issue open for it?)

Thanks!

shawwn avatar Sep 08 '21 03:09 shawwn

Okay, I've fixed block pagination. See PR #345

shawwn avatar Sep 08 '21 04:09 shawwn