qax-os/excelize · error

incorrect number of tokens in criteria %q

Error message

incorrect number of tokens in criteria %q

What it means

Error from newInvalidAutoFilterExpError, an autoFilter helper raised when a filter criteria expression does not split into the expected number of tokens (operator plus operand); at fault is the criteria string passed to auto filter APIs.

Source

Thrown at errors.go:261

	return fmt.Errorf("invalid cell reference [%d, %d]", col, row)
}

// newFieldLengthError defined the error message on receiving the field length
// overflow.
func newFieldLengthError(name string) error {
	return fmt.Errorf("field %s must be less than or equal to 255 characters", name)
}

// newInvalidAutoFilterColumnError defined the error message on receiving the
// incorrect index of column.
func newInvalidAutoFilterColumnError(col string) error {
	return fmt.Errorf("incorrect index of column %q", col)
}

// newInvalidAutoFilterExpError defined the error message on receiving the
// incorrect number of tokens in criteria expression.
func newInvalidAutoFilterExpError(exp string) error {
	return fmt.Errorf("incorrect number of tokens in criteria %q", exp)
}

// newInvalidAutoFilterOperatorError defined the error message on receiving the
// incorrect expression operator.
func newInvalidAutoFilterOperatorError(op, exp string) error {
	return fmt.Errorf("the operator %q in expression %q is not valid in relation to Blanks/NonBlanks", op, exp)
}

// newInvalidCellNameError defined the error message on receiving the invalid
// cell name.
func newInvalidCellNameError(cell string) error {
	return fmt.Errorf("invalid cell name %q", cell)
}

// newInvalidColumnNameError defined the error message on receiving the
// invalid column name.
func newInvalidColumnNameError(col string) error {
	return fmt.Errorf("invalid column name %q", col)

View on GitHub (pinned to f2483381fb)

Solutions

  1. Reformat the criteria as `<operator> <value>`
  2. Quote values containing spaces so tokenization succeeds
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at errors.go:261 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02). Data as JSON: /api/errors/a4d3dbd67d0a1c87. Report an issue: GitHub.