flarum/framework · error · BadRequestException
page[offset] must be at least 0
Error message
page[offset] must be at least 0
What it means
Guard in RequestUtil::extractOffset: when paginating with page[offset], a negative offset is meaningless (offsets index into the result set from 0), so a 400 BadRequestException is thrown. Requests using page[number] never reach this branch.
Solutions
- Use page[offset] >= 0
- Use page[number] pagination instead of raw offsets
- Fix client code that computes a negative offset (e.g. page counter underflow)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at framework/core/src/Http/RequestUtil.php:197 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15).
Data as JSON: /api/errors/40813759cf59157c.
Report an issue: GitHub.
Appendix: source
Thrown at framework/core/src/Http/RequestUtil.php:197
$page = (int) ($request->getQueryParams()['page']['number'] ?? 1);
if ($page < 1) {
throw new BadRequestException('page[number] must be at least 1');
}
return ($page - 1) * $limit;
}
public static function extractOffset(Request $request, ?int $limit = 0): int
{
if ($request->getQueryParams()['page']['number'] ?? false) {
return self::extractOffsetFromNumber($request, $limit);
}
$offset = (int) ($request->getQueryParams()['page']['offset'] ?? 0);
if ($offset < 0) {
throw new BadRequestException('page[offset] must be at least 0');
}
return $offset;
}
public static function extractInclude(Request $request, ?array $available): array
{
$include = $request->getQueryParams()['include'] ?? '';
if (! is_string($include)) {
throw new BadRequestException('include must be a string');
}
$includes = array_filter(explode(',', $include));
$invalid = array_diff($includes, $available);
if (count($invalid)) {View on GitHub (pinned to 4b939f6853)