Chapter GET list API stops counting book IDs past 85 existing books #4366

Closed
opened 2026-02-05 08:41:19 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @whimsee on GitHub (Dec 18, 2023).

Describe the Bug

I ran into a bit of an issue with the JSON response when I GET the list of chapters after reaching 85 books. Basically, I've hooked up a python script to the API that looks up whether a Book/Chapter exists and creates them if they don't before making pages under them.

It worked pretty well until it just started creating new chapters for each page. This is partly because of my code, which looks up book name --> book_id then chapter name --> chapter_id (to make sure the book is present first), but this is also because after reaching 85 existing books (had to delete and remake books and get below that number to make sure it wasn't some fluke but it could still be), GETting the chapter list only gives you the first 85 books. I was wondering if it just didn't read the entire request but it did end in "total", which gave the right chapter count.

Books past that still exist (the new chapters do show up in the right book since the book list is complete, just with a different ID each time since it couldn't find the Book in the chapter list to get the existing chapter ID) and the chapters can still be referred to if you know the ID (by reading the POST request), but this doesn't seem like intended behavior.

Edit: could also be possible it's because I've coincidentally made exactly 100 chapters as well before it broke (since some books have several chapters), but I'll have to check that another time.

Steps to Reproduce

  1. Create 85 books (around 5 pages worth in List view) with different names via API. Each of them should have at least one chapter.
  2. Create one more book via API and note the name and ID. Add a chapter to it as well.
  3. GET Chapter list via API and check if Book no. 86 is present in the JSON response.

Expected Behaviour

Book no. 86's information should be present after Book no. 85, and it should be possible to confirm by checking its unique book ID (and name for good measure). Right now that is not the case as it ends at Book no. 85.

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

BookStack v23.10.4

Originally created by @whimsee on GitHub (Dec 18, 2023). ### Describe the Bug I ran into a bit of an issue with the JSON response when I GET the list of chapters after reaching 85 books. Basically, I've hooked up a python script to the API that looks up whether a Book/Chapter exists and creates them if they don't before making pages under them. It worked pretty well until it just started creating new chapters for each page. This is partly because of my code, which looks up book name --> book_id then chapter name --> chapter_id (to make sure the book is present first), but this is also because after reaching 85 existing books (had to delete and remake books and get below that number to make sure it wasn't some fluke but it could still be), GETting the chapter list only gives you the first 85 books. I was wondering if it just didn't read the entire request but it did end in "total", which gave the right chapter count. Books past that still exist (the new chapters do show up in the right book since the book list is complete, just with a different ID each time since it couldn't find the Book in the chapter list to get the existing chapter ID) and the chapters can still be referred to if you know the ID (by reading the POST request), but this doesn't seem like intended behavior. Edit: could also be possible it's because I've coincidentally made exactly 100 chapters as well before it broke (since some books have several chapters), but I'll have to check that another time. ### Steps to Reproduce 1. Create 85 books (around 5 pages worth in List view) with different names via API. Each of them should have at least one chapter. 2. Create one more book via API and note the name and ID. Add a chapter to it as well. 3. GET Chapter list via API and check if Book no. 86 is present in the JSON response. ### Expected Behaviour Book no. 86's information should be present after Book no. 85, and it should be possible to confirm by checking its unique book ID (and name for good measure). Right now that is not the case as it ends at Book no. 85. ### Screenshots or Additional Context _No response_ ### Browser Details _No response_ ### Exact BookStack Version BookStack v23.10.4
OVERLORD added the 🐛 Bug label 2026-02-05 08:41:19 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Dec 18, 2023):

Hi @whimsee,
There's nothing that should really result in this behaviour as an issue, but I just double checked this on my dev instance by creating an extra 100 or so books, then checking a new chapter against that, and all appears fine.

Are you sure you're not just reaching the per-page-item limit in the original GET chapters response? Therefore you're not seeing the added chapters?

By default the listing API page size is 100. You can test showing more by adding ?count=500 to the API request.
The details and options for paging are in the docs under a "Listing Endpoints" header within the "Getting Started" part of the docs at the top.

@ssddanbrown commented on GitHub (Dec 18, 2023): Hi @whimsee, There's nothing that should really result in this behaviour as an issue, but I just double checked this on my dev instance by creating an extra 100 or so books, then checking a new chapter against that, and all appears fine. Are you sure you're not just reaching the per-page-item limit in the original GET chapters response? Therefore you're not seeing the added chapters? By default the listing API page size is 100. You can test showing more by adding `?count=500` to the API request. The details and options for paging are in the docs under a "Listing Endpoints" header within the "Getting Started" part of the docs at the top.
Author
Owner

@whimsee commented on GitHub (Dec 18, 2023):

Ah. That explains it. Hadn't accounted for it until now and yes, it does work after I set the count higher than 100, which meant the chapter count was the culprit. Thanks for pointing that out! @ssddanbrown

@whimsee commented on GitHub (Dec 18, 2023): Ah. That explains it. Hadn't accounted for it until now and yes, it does work after I set the count higher than 100, which meant the chapter count was the culprit. Thanks for pointing that out! @ssddanbrown
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#4366