{"record":{"id":"2c66b9ccda535c4c","repo":"flarum/framework","slug":"filter-must-be-an-array","errorCode":null,"errorMessage":"filter must be an array","messagePattern":"filter must be an array","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"framework/core/src/Http/RequestUtil.php","lineNumber":227,"sourceCode":"        }\n\n        $includes = array_filter(explode(',', $include));\n\n        $invalid = array_diff($includes, $available);\n\n        if (count($invalid)) {\n            throw new BadRequestException('Invalid includes ['.implode(',', $invalid).']');\n        }\n\n        return $includes;\n    }\n\n    public static function extractFilter(Request $request): array\n    {\n        $filter = $request->getQueryParams()['filter'] ?? [];\n\n        if (! is_array($filter)) {\n            throw new BadRequestException('filter must be an array');\n        }\n\n        return $filter;\n    }\n\n    public static function extractFields(Request $request, ?array $available = null): array\n    {\n        $fields = $request->getQueryParams()['fields'] ?? [];\n\n        if (! is_array($fields)) {\n            throw new BadRequestException('fields must be an array');\n        }\n\n        if ($available !== null) {\n            $invalid = array_diff(array_keys($fields), $available);\n\n            if (count($invalid)) {\n                throw new BadRequestException('Invalid fields ['.implode(',', $invalid).']');","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Http/RequestUtil.php#L209-L245","documentation":"Guard in RequestUtil::extractFilter: the 'filter' query parameter must be an object/array of filter criteria (e.g. ?filter[author]=...). If a client sends filter as a scalar string, it cannot be mapped to filterable query keys, so a 400 BadRequestException is thrown.","triggerScenarios":"Thrown at framework/core/src/Http/RequestUtil.php:227 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send filters in object form: ?filter[q]=term or ?filter[author]=1","Do not send ?filter=scalarValue","Fix the client query serialization so filter is always a keyed object"],"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"}