temporalio/temporal · error

invalid filter: %s

Error message

invalid filter: %s

What it means

The matching task query engine validates worker query filters (visibility list-filter queries) via prepareQuery, called by validateQuery. Filters must be a bare WHERE clause; a query starting with 'where ' or 'select ' is rejected because the engine itself wraps the expression in 'select * from table1 where ...', so a leading keyword would produce invalid SQL.

Source

Thrown at service/matching/workers/worker_query_engine.go:199

		return nil, serviceerror.NewInvalidArgumentf("%s: 'limit' clause", notSupportedErrMessage)
	}

	if selectStmt.Where == nil {
		return nil, serviceerror.NewInvalidArgumentf("%s: 'where' clause is missing", notSupportedErrMessage)
	}

	return selectStmt.Where.Expr, nil
}

func prepareQuery(query string) (string, error) {
	query = strings.TrimSpace(query)
	if query == "" {
		return "", nil
	}

	if strings.HasPrefix(strings.ToLower(query), "where ") ||
		strings.HasPrefix(strings.ToLower(query), "select ") {
		return "", fmt.Errorf("invalid filter: %s", query)
	}

	// sqlparser can't parse just WHERE clause but instead accepts only valid SQL statement.
	query = fmt.Sprintf("select * from table1 where %s", query)

	return query, nil
}

func (w *workerQueryEngine) evaluateExpression(expr sqlparser.Expr) (bool, error) {

	if expr == nil {
		return false, serviceerror.NewInvalidArgumentf("input expression cannot be nil")
	}

	switch e := (expr).(type) {
	case *sqlparser.AndExpr:
		return w.evaluateAnd(e)
	case *sqlparser.OrExpr:

View on GitHub (pinned to bde624efd1)

Solutions

  1. Strip the leading 'WHERE ' from the filter and pass only the predicate, e.g. `ExecutionStatus = 'Running'` instead of `WHERE ExecutionStatus = 'Running'`
  2. If you used a full SELECT statement, reduce it to just the WHERE-clause expression
  3. Ensure the client/SDK is not auto-prefixing 'where' before sending the query

Example fix

// before
query := "WHERE TaskType = 'workflow' AND BuildId = 'v1'"

// after
query := "TaskType = 'workflow' AND BuildId = 'v1'"
Defensive patterns

Strategy: validation

Validate before calling

func validateTaskQueueFilter(query string) error {
	q := strings.TrimSpace(strings.ToLower(query))
	if strings.HasPrefix(q, "where ") || strings.HasPrefix(q, "select ") {
		return fmt.Errorf("pass only the WHERE-clause expression, not %q", query)
	}
	return nil
}

Prevention

When it happens

Trigger: Passing a list filter like "WHERE ExecutionStatus='Running'" or a full "SELECT ..." statement to worker query validation (e.g. DescribeTaskQueue with query, or the list-filter used by tctl taskqueue describe / worker visibility), instead of the expression alone.

Common situations: Users copying SQL-style examples or full visibility queries into the task-queue filter field; client SDKs or scripts that prepend 'WHERE'; confusion between Search Attribute visibility queries and task-queue worker filters.

Related errors


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/2ad79f3a456fd14f. Report an issue: GitHub.