{"record":{"id":"ceaade7d5e061d8a","repo":"flarum/framework","slug":"sort-must-be-a-string","errorCode":null,"errorMessage":"sort must be a string","messagePattern":"sort must be a string","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"framework/core/src/Http/RequestUtil.php","lineNumber":123,"sourceCode":"        $actorReference->setActor($actor);\n\n        return $request;\n    }\n\n    public static function extractSort(Request $request, ?string $default, array $available = []): ?array\n    {\n        $input = $request->getQueryParams()['sort'] ?? null;\n\n        if (is_null($input) || ! filled($input)) {\n            $input = $default;\n        }\n\n        if (! $input) {\n            return null;\n        }\n\n        if (! is_string($input)) {\n            throw new BadRequestException('sort must be a string');\n        }\n\n        $sort = [];\n\n        foreach (explode(',', $input) as $field) {\n            if (str_starts_with($field, '-')) {\n                $field = substr($field, 1);\n                $order = 'desc';\n            } else {\n                $order = 'asc';\n            }\n\n            $sort[$field] = $order;\n        }\n\n        $invalid = array_diff(array_keys($sort), $available);\n\n        if (count($invalid)) {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Http/RequestUtil.php#L105-L141","documentation":"Validation-helper guard in RequestUtil::extractSort: the 'sort' query parameter, used by list endpoints to order results, must be a comma-separated string like '-createdAt,name'. If a client sends sort as an array (repeated ?sort[]= params) or any non-string value, it cannot be parsed, so a 400 BadRequestException is thrown.","triggerScenarios":"Thrown at framework/core/src/Http/RequestUtil.php:123 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send sort as a single string: ?sort=-createdAt","Do not use array params (?sort[]=...)","Fix the client serialization so sort is emitted once as a comma-separated list"],"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"}