[2.x] A filter on a resource without a searcher returns a 500

Open
#5,578 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@imorland is already working on this.

Since Nov 23, 2026.

Assessment

This issue has not been assessed yet.

Description

type/bug
Current Behavior

Any filter[...] on a list endpoint whose resource has no searcher returns a 500:

RuntimeException: Not supported in Flarum, please use a model searcher instead https://docs.flarum.org/extend/search.

Api\Endpoint\Index uses the search manager only for searchable models. For other resources it calls applyFilters(), which calls AbstractDatabaseResource::filters(), and that method always throws. A client mistake therefore surfaces as a server error. This happens on every database driver.

Steps to Reproduce
  1. Enable flarum/flags (its flags resource has no searcher).
  2. As an admin, request GET /api/flags?filter[id]=1.
  3. The response is a 500 with the exception above.
Expected Behavior

A 400, as json-api-server's apply_filters() gives for a filter a resource doesn't define (Invalid filter: <name>).

Environment
  • Flarum: 2.x @ b43a84be3
  • Reproduced on PostgreSQL 18; the code path doesn't depend on the driver.
Possible Solution

In Index, when the model isn't searchable and the request has filters, throw the same BadRequestException instead of reaching filters().

Dominant language
PHP
Stars
6.8k
Forks
891
Avg merge
1d 10h
Merged PRs (30d)
209

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flarum/framework

All issues in flarum/framework

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.