googleapis/mcp-toolbox · error

filter at index %d is not a string

Error message

filter at index %d is not a string

What it means

Element-type guard in parseFilters: an entry of the filters array is not a string. Each filter must arrive as a JSON-encoded string, not a raw object or number.

Source

Thrown at internal/tools/firestore/firestorequerycollection/firestorequerycollection.go:366

	return result, nil
}

// parseFilters parses and validates filter configurations
func (t Tool) parseFilters(filtersRaw interface{}) ([]FilterConfig, error) {
	filters, ok := filtersRaw.([]any)
	if !ok {
		return nil, fmt.Errorf(errInvalidFilters, filtersKey)
	}

	if len(filters) > maxFilterLength {
		return nil, fmt.Errorf(errTooManyFilters, len(filters), maxFilterLength)
	}

	result := make([]FilterConfig, 0, len(filters))
	for i, filterRaw := range filters {
		filterJSON, ok := filterRaw.(string)
		if !ok {
			return nil, fmt.Errorf(errFilterNotString, i)
		}

		var filter FilterConfig
		if err := json.Unmarshal([]byte(filterJSON), &filter); err != nil {
			return nil, fmt.Errorf(errFilterParseFailed, i, err)
		}

		if err := filter.Validate(); err != nil {
			return nil, fmt.Errorf("filter at index %d is invalid: %w", i, err)
		}

		result = append(result, filter)
	}

	return result, nil
}

// parseOrderBy parses the orderBy configuration

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. JSON-encode each filter object into a string before sending
  2. Do not mix raw objects into the filters array
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/tools/firestore/firestorequerycollection/firestorequerycollection.go:366 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/e9b967f5cb4b2802. Report an issue: GitHub.