Cursor invalid
CURSOR_INVALID comes with HTTP 400. The cursor you sent to POST /v3/articles/search cannot be read.
What it means
A cursor is the value of pagination.nextCursor from the previous page. It is opaque: the API only accepts cursors exactly as it gave them out. This error means the value is not such a cursor. It was changed, cut off, built by hand, or comes from an older cursor format.
Cursors do not expire. A cursor you got from the API stays readable.
Example response
cURL
curl -X POST 'https://api.finlight.me/v3/articles/search' \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: YOUR_API_KEY' \
-H 'X-Request-Id: req-123' \
-d '{ "cursor": "not-a-cursor" }'
Response (400)
{
"type": "https://docs.finlight.me/errors/cursor-invalid",
"title": "Cursor invalid",
"status": 400,
"detail": "The cursor is not a valid base64url-encoded value.",
"code": "CURSOR_INVALID",
"requestId": "req-123",
"errors": [
{ "field": "cursor", "issue": "The cursor is not a valid base64url-encoded value." }
]
}
Common causes
detail | Cause |
|---|---|
The cursor is not a valid base64url-encoded value. | The value was cut off, changed or made up. Check that you pass nextCursor unchanged, for example without extra quotes or URL encoding. |
The cursor does not carry the expected fields. | The value can be decoded but is not a finlight cursor. |
Unsupported cursor version '2'. | The cursor comes from a format this API does not support. |
How to fix
- Pass
pagination.nextCursorfrom the last response exactly as you got it. - If you no longer have a valid cursor, start the search again without
cursor. - Stop paging when
hasMoreisfalse. ThennextCursorisnull; do not send it.
See Pagination.
Retry
Do not retry. The same cursor fails again. The client libraries never retry it, and searchAll stops with this error.
In the SDKs
| Language | Error |
|---|---|
| TypeScript, Python, Ruby | CursorInvalidError |
| .NET, Java, PHP | CursorInvalidException |
| Go | *finlight.APIError with APIKind == finlight.APIKindCursorInvalid |
| Rust | Error::Api with api_kind() == ApiErrorKind::CursorInvalid |
searchAll (Python: search_all) handles the cursor for you, so this error only shows up when you pass a cursor yourself.
Catch a cursor error
import { CursorInvalidError } from 'finlight-client'
try {
await client.articles.search({ query: 'ticker:NVDA', cursor: savedCursor })
} catch (err) {
if (err instanceof CursorInvalidError) {
// Start again from the first page
await client.articles.search({ query: 'ticker:NVDA' })
} else {
throw err
}
}