googleapis/mcp-toolbox · error
column 'object_details' is not a string, but %T
Error message
column 'object_details' is not a string, but %T
What it means
In processRows (internal/sources/spanner/spanner.go:153), the Spanner source expects a column's value to convert to a Go string via val.AsInterface().(string) — this is used to parse JSON 'object_details' columns into maps. When the Spanner value's underlying Go type is not a string (e.g. []byte, int64, float64, bool), the type assertion fails and this error is returned. It indicates the query returned a non-JSON/non-string value in a column the code path treats as a JSON string payload.
Source
Thrown at internal/sources/spanner/spanner.go:153
row, err := iter.Next()
if err == iterator.Done {
break
}
if err != nil {
return nil, fmt.Errorf("unable to parse row: %w", err)
}
rowMap := orderedmap.Row{}
cols := row.ColumnNames()
for i, c := range cols {
if c == "object_details" { // for list graphs or list tables
val := row.ColumnValue(i)
if val == nil { // ColumnValue returns the Cloud Spanner Value of column i, or nil for invalid column.
rowMap.Add(c, nil)
} else {
jsonString, ok := val.AsInterface().(string)
if !ok {
return nil, fmt.Errorf("column 'object_details' is not a string, but %T", val.AsInterface())
}
var details map[string]any
if err := json.Unmarshal([]byte(jsonString), &details); err != nil {
return nil, fmt.Errorf("unable to unmarshal JSON: %w", err)
}
rowMap.Add(c, details)
}
} else {
rowMap.Add(c, row.ColumnValue(i))
}
}
out = append(out, rowMap)
}
return out, nil
}
func (s *Source) RunSQL(ctx context.Context, readOnly bool, statement string, params map[string]any) (any, error) {
var results []anyView on GitHub (pinned to 8cc6e09de2)
Solutions
- Inspect the column types in your query result and ensure the JSON payload column is a Spanner STRING
- Cast the column in SQL: SELECT CAST(object_details AS STRING) AS object_details ...
- If the value arrives as []byte, convert with string(val) before unmarshalling in processRows
- Check for recent schema migrations that changed the column's type away from STRING
Example fix
// before SELECT object_details FROM objects; // after SELECT CAST(object_details AS STRING) AS object_details FROM objects;
Defensive patterns
Strategy: type-guard
Validate before calling
// verify the column is STRING before running the tool // in Spanner: SELECT column_name, spanner_type FROM information_schema.columns WHERE table_name = 'objects';
Type guard
func asJSONString(v any) (string, bool) {
s, ok := v.(string)
if !ok {
if b, ok2 := v.([]byte); ok2 {
return string(b), true
}
return "", false
}
return s, true
} Prevention
- Keep JSON payload columns as Spanner STRING type
- CAST in SQL when column type may vary
- Assert the schema in CI with information_schema checks
When it happens
Trigger: Calling RunSQL/InvokeSearchCatalog through the Spanner source where a result column's value from row.ColumnValue(i).AsInterface() is not a string — e.g. the search/catalog query returns numeric or []byte columns instead of JSON text.
Common situations: Spanner returning JSON columns as []byte with certain drivers/settings; a schema change altered a column from STRING to NUMERIC/BOOL; using a custom SQL query that selects non-string columns into a code path expecting 'object_details' JSON.
Related errors
- unable to unmarshal JSON: %w
- unable to execute client: %w
- unable to create new client: %w
- invalid source for %q tool: source %q is not a compatible ty
- source is not compatible with the tool
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/70a4218e2c9089ac.
Report an issue: GitHub.