toeverything/AFFiNE · warning · BadRequest
bad_request
bad_request
Error message
Invalid pagination cursor
What it means
Thrown by parseCursorDate (workspace-analytics.ts:220) when new Date(value) returns an Invalid Date (getTime() is NaN) — the value was the right type but did not parse to a real date. UserFriendlyError BadRequest, code bad_request, HTTP 400.
Source
Thrown at packages/backend/server/src/models/workspace-analytics.ts:220
return decodeWithJson<T>(raw);
} catch {
throw new BadRequest('Invalid pagination cursor');
}
}
}
function parseCursorDate(value: unknown): Date {
if (
typeof value !== 'string' &&
typeof value !== 'number' &&
!(value instanceof Date)
) {
throw new BadRequest('Invalid pagination cursor');
}
const parsed = new Date(value);
if (Number.isNaN(parsed.getTime())) {
throw new BadRequest('Invalid pagination cursor');
}
return parsed;
}
function parseCursorNumber(value: unknown): number {
const parsed = Number(value);
if (!Number.isFinite(parsed)) {
throw new BadRequest('Invalid pagination cursor');
}
return parsed;
}
function parseCursorString(value: unknown): string {
if (typeof value !== 'string' || !value) {
throw new BadRequest('Invalid pagination cursor');
}
return value;
}View on GitHub (pinned to 26c515e050)
Solutions
- Restart pagination from page 1 to regenerate the cursor.
- Ensure cursors originate only from server responses.
- Validate/normalize date strings before persisting them.
Defensive patterns
Strategy: validation
Validate before calling
function isValidCursorDate(v: unknown): boolean {
if (typeof v !== 'string' && typeof v !== 'number' && !(v instanceof Date)) return false;
return !Number.isNaN(new Date(v).getTime());
} Prevention
- Validate that date fields parse to real dates before sending.
- Drop and restart from page 1 on an unparseable date cursor.
- Only forward server-issued cursors unchanged.
When it happens
Trigger: A cursor date field that is a string like "not-a-date" or a malformed/truncated ISO string, or a number that is not a valid epoch timestamp.
Common situations: Truncated ISO string in a cached cursor; locale-formatted date slipped in; non-numeric garbage typed into the field; stale cursor across a format change.
Related errors
AI-assisted analysis of toeverything/AFFiNE@26c515e050 (2026-08-12).
Data as JSON: /api/errors/cfbcd3550ba3d640.
Report an issue: GitHub.