googleapis/mcp-toolbox · error

can't convert pivots to array of strings: %s

Error message

can't convert pivots to array of strings: %s

What it means

ProcessQueryArgs converts the raw 'pivots' parameter (declared as []any) into a []string via parameters.ConvertAnySliceToTyped. When any element in the pivots slice cannot be converted to a string (e.g. it is a number, bool, map, or nil), the helper returns an error and this wrapper wraps it. It aborts building the Looker run-inline-query request body.

Source

Thrown at internal/tools/looker/lookercommon/lookercommon.go:328

	// rather than mutating during iteration, and avoid comparing `any` values
	// directly (non-comparable dynamic types like slices would panic).
	processedFilters := make(map[string]any, len(filters))
	for k, v := range filters {
		newKey := k
		if len(k) >= 2 && (k[0] == '\'' || k[0] == '"') && k[0] == k[len(k)-1] {
			newKey = k[1 : len(k)-1]
		}
		newVal := v
		if s, ok := v.(string); ok && len(s) >= 2 &&
			(s[0] == '\'' || s[0] == '"') && s[0] == s[len(s)-1] {
			newVal = s[1 : len(s)-1]
		}
		processedFilters[newKey] = newVal
	}
	filters = processedFilters
	p, err := parameters.ConvertAnySliceToTyped(paramsMap["pivots"].([]any), "string")
	if err != nil {
		return nil, fmt.Errorf("can't convert pivots to array of strings: %s", err)
	}
	pivots := p.([]string)
	s, err := parameters.ConvertAnySliceToTyped(paramsMap["sorts"].([]any), "string")
	if err != nil {
		return nil, fmt.Errorf("can't convert sorts to array of strings: %s", err)
	}
	sorts := s.([]string)
	limit := fmt.Sprintf("%v", paramsMap["limit"].(int))

	var tz string
	if paramsMap["tz"] != nil {
		tz = paramsMap["tz"].(string)
	} else {
		tzname, err := tzlocal.RuntimeTZ()
		if err != nil {
			logger.ErrorContext(ctx, fmt.Sprintf("Error getting local timezone: %s", err))
			tzname = "Etc/UTC"
		}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Ensure every element of the pivots parameter is a JSON string (view/field names), e.g. ["users.city","orders.count"]
  2. Check the tool's parameter schema and send pivots as an array, not an object or scalar
  3. If building parameters programmatically, convert values with fmt.Sprintf("%v", v) before passing
  4. Update the calling client so it respects the declared array-of-strings parameter type

Example fix

// before
"pivots": [1, 2]
// after
"pivots": ["users.state", "orders.status"]
Defensive patterns

Strategy: validation

Validate before calling

func validPivots(v any) bool {
	s, ok := v.([]any)
	if !ok { return false }
	for _, e := range s {
		if _, ok := e.(string); !ok { return false }
	}
	return true
}

Type guard

if p, ok := params["pivots"].([]any); ok && allStrings(p) { /* safe */ }

Prevention

When it happens

Trigger: Calling a Looker query tool (e.g. invoke run_inline_query style tools) with pivots supplied as non-string values, such as pivots: [1, 2] or pivots: [{"field": "x"}], or pivots not being an array at all (the paramsMap["pivots"].([]any) assertion would panic separately).

Common situations: LLM/agent clients filling parameters from JSON supply numeric or object values instead of field-name strings; hand-written configs quoting pivots inconsistently; schemas that accept free-form arrays letting wrong types slip through.

Related errors


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