pocketbase/pocketbase · error · ErrEmptyQuery

search query is not set

Error message

search query is not set

What it means

Error "search query is not set" thrown in pocketbase/pocketbase.

Source

Thrown at tools/search/provider.go:39

	// DefaultFilterExprLimit specifies the default filter expressions limit.
	DefaultFilterExprLimit int = 200

	// DefaultSortExprLimit specifies the default sort expressions limit.
	DefaultSortExprLimit int = 8

	// MaxPerPage specifies the max allowed search result items returned in a single page.
	MaxPerPage int = 1000

	// MaxFilterLength specifies the max allowed individual search filter parsable length.
	MaxFilterLength int = 3500

	// MaxSortFieldLength specifies the max allowed individual sort field parsable length.
	MaxSortFieldLength int = 255
)

// Common search errors.
var (
	ErrEmptyQuery           = errors.New("search query is not set")
	ErrSortExprLimit        = errors.New("max sort expressions limit reached")
	ErrFilterExprLimit      = errors.New("max filter expressions limit reached")
	ErrFilterLengthLimit    = errors.New("max filter length limit reached")
	ErrSortFieldLengthLimit = errors.New("max sort field length limit reached")
)

// URL search query params
const (
	PageQueryParam      string = "page"
	PerPageQueryParam   string = "perPage"
	SortQueryParam      string = "sort"
	FilterQueryParam    string = "filter"
	SkipTotalQueryParam string = "skipTotal"
)

// Result defines the returned search result structure.
type Result struct {
	Items      any `json:"items"`

View on GitHub (pinned to 5d217ddb50)

Solutions

  1. Set a non-empty search query before executing the search request.
  2. If the query comes from user input, trim and validate it, and reject empty submissions client-side.

Example fix

q := strings.TrimSpace(input)
if q == "" {
    return errors.New("search query is required")
}
results, err := provider.Search(q)

When it happens

Trigger: Thrown when a search provider query is executed without the search query (filter/sort input) being set.

Common situations: The provider is executed before its query string is assigned. Initialize the provider with a non-empty query before calling Exec.


AI-assisted analysis of pocketbase/pocketbase@5d217ddb50 (2026-08-15). Data as JSON: /api/errors/a03d0df21fc6898c. Report an issue: GitHub.