{"record":{"id":"c0d17ca5e2bba810","repo":"flarum/framework","slug":"page-limit-must-be-at-least-1","errorCode":null,"errorMessage":"page[limit] must be at least 1","messagePattern":"page\\[limit\\] must be at least 1","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"framework/core/src/Http/RequestUtil.php","lineNumber":171,"sourceCode":"\n        if (! filled($limit)) {\n            $limit = $defaultLimit;\n        }\n\n        // Only short-circuit when there is genuinely no limit (no page[limit] and no\n        // default). A loose `! $limit` check here also caught the string \"0\", returning\n        // null which then broke OffsetPagination's non-nullable int $limit. An explicit\n        // page[limit]=0 must instead fall through to the `< 1` guard below and 400.\n        if ($limit === null) {\n            return null;\n        }\n\n        if ($max !== null) {\n            $limit = min($limit, $max);\n        }\n\n        if ($limit < 1) {\n            throw new BadRequestException('page[limit] must be at least 1');\n        }\n\n        return $limit;\n    }\n\n    public static function extractOffsetFromNumber(Request $request, int $limit): int\n    {\n        $page = (int) ($request->getQueryParams()['page']['number'] ?? 1);\n\n        if ($page < 1) {\n            throw new BadRequestException('page[number] must be at least 1');\n        }\n\n        return ($page - 1) * $limit;\n    }\n\n    public static function extractOffset(Request $request, ?int $limit = 0): int\n    {","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Http/RequestUtil.php#L153-L189","documentation":"Guard in RequestUtil::extractLimit: after falling back to the default limit and clamping to the optional maximum, a page[limit] value resolving to less than 1 (typically an explicit page[limit]=0 or a negative number) is invalid for pagination, so a 400 BadRequestException is thrown. A missing/empty limit returns null instead; only a genuinely non-positive requested limit hits this guard.","triggerScenarios":"Thrown at framework/core/src/Http/RequestUtil.php:171 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Request page[limit] >= 1","Omit page[limit] entirely to use the endpoint's default limit","Fix client code that computes the limit (e.g. pageSize 0) before calling the API"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}