{"record":{"id":"cbefbb9e00adee7f","repo":"appwrite/appwrite","slug":"general-cursor-not-found-cbefbb","errorCode":"general_cursor_not_found","errorMessage":"Collection '{$collectionIdId}' for the 'cursor' value not found.","messagePattern":"Collection '(.+?)' for the 'cursor' value not found\\.","errorType":"exception","errorClass":"Appwrite\\Extend\\Exception","httpStatus":400,"severity":"error","filePath":"src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php","lineNumber":106,"sourceCode":"\n        if (!empty($search)) {\n            $queries[] = Query::search('search', $search);\n        }\n\n        $cursor = Query::getCursorQueries($queries, false);\n        $cursor = \\reset($cursor);\n\n        if ($cursor !== false) {\n            $validator = new Cursor();\n            if (!$validator->isValid($cursor)) {\n                throw new Exception(Exception::GENERAL_QUERY_INVALID, $validator->getDescription());\n            }\n\n            $collectionIdId = $cursor->getValue();\n            $cursorDocument = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionIdId);\n\n            if ($cursorDocument->isEmpty()) {\n                throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, ucfirst($this->getContext()) . \" '$collectionIdId' for the 'cursor' value not found.\");\n            }\n\n            $cursor->setValue($cursorDocument);\n        }\n\n        try {\n            $collections = $dbForProject->find('database_' . $database->getSequence(), $queries);\n            $total = $includeTotal ? $dbForProject->count('database_' . $database->getSequence(), $queries, APP_LIMIT_COUNT) : 0;\n        } catch (OrderException) {\n            throw new Exception(Exception::DATABASE_QUERY_ORDER_NULL);\n        } catch (QueryException) {\n            throw new Exception(Exception::GENERAL_QUERY_INVALID);\n        }\n\n        foreach ($collections as $collection) {\n            $this->addRowBytesInfo($collection, $dbForProject);\n        }\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/appwrite/appwrite/blob/a1d520eea492ebd1da1ef2dc8db5b2b34e277dce/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php#L88-L124","documentation":"The cursor value sent to GET /v1/databases/{databaseId}/collections names a collection that does not exist in this database. After the Cursor validator passes, the endpoint loads the cursor document from the per-database metadata collection (database_{internalId}); an empty result means pagination cannot continue from that anchor, so GENERAL_CURSOR_NOT_FOUND is raised with the offending ID.","triggerScenarios":"Query.cursor('collectionId') where the ID was deleted, belongs to another database, or is a typo; paginating while another client deletes collections between page requests; reusing a cursor saved from a different environment (dev vs prod).","commonSituations":"Persisting cursors long-term and replaying them after deletions; concurrent admin operations pruning collections during a paginated export; copy-pasting cursor IDs between projects.","solutions":["Re-fetch from the first page without a cursor and paginate again.","Verify the anchor exists first: GET /v1/databases/{dbId}/collections/{cursorId} should return 200.","If deletions are frequent, derive each cursor from the immediately preceding response instead of stored state."],"exampleFix":"// before\nconst next = await databases.listCollections(dbId, [Query.cursorAfter(savedCursorId)]);\n\n// after\ntry {\n  const next = await databases.listCollections(dbId, [Query.cursorAfter(savedCursorId)]);\n} catch (e) {\n  if (e.code === 'general_cursor_not_found') {\n    return databases.listCollections(dbId, [Query.limit(limit)]); // anchor deleted -> restart\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"async function cursorExists(databases, dbId, cursorId) {\n  try {\n    await databases.getCollection(dbId, cursorId);\n    return true;\n  } catch {\n    return false;\n}\n// if (!await cursorExists(...)) restart from the first page","typeGuard":null,"tryCatchPattern":"try {\n  return await databases.listCollections(dbId, [Query.cursorAfter(cursorId)]);\n} catch (e) {\n  if (e.code === 'general_cursor_not_found') {\n    return databases.listCollections(dbId, [Query.limit(limit)]); // anchor gone: restart at page 1\n  }\n  throw e;\n}","preventionTips":["Use cursors taken from the immediately preceding page response","Restart pagination from the first page when deletions are possible","Never persist cursors across sessions or environments"],"tags":["databases","collections","pagination","cursor","not-found"],"backgroundTag":"pagination-cursor-not-found","analyzedSha":"a1d520eea492ebd1da1ef2dc8db5b2b34e277dce","analyzedAt":"2026-08-18T21:34:56.994Z","contentChangedAt":"2026-08-18T21:34:56.994Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}