API pagination returns "nil" bookmark for empty decks, causing HTTP 500

API pagination returns "nil" bookmark for empty decks, causing HTTP 500

Hi,

I encountered an issue with the card-listing API.

Steps to reproduce

  1. Create an empty deck.
  2. Request its cards:

GET /api/cards/?deck-id=&limit=100

  1. The response contains:

{ "docs": [], "bookmark": "nil" }

  1. Following that bookmark:

GET /api/cards/?deck-id=&limit=100&bookmark=nil

returns:

HTTP 500

{"errors":["Something went wrong."]}

Expected behavior

For an empty or final page, the API should ideally return a missing, null, or empty bookmark. Alternatively, passing the returned "nil" bookmark should produce an empty page rather than an HTTP 500.

This makes generic pagination loops fail unless they explicitly treat the string "nil" as a terminal value.

Thanks!