googleapis/mcp-toolbox · error

invalid map value format

Error message

invalid map value format

What it means

Shape guard in JSONToFirestoreValue for mapValue: the value is not a map with a `fields` object (or is not a map at all), so its entries cannot be enumerated.

Source

Thrown at internal/tools/firestore/util/converter.go:137

						}
					}
					return nil, fmt.Errorf("invalid array value format")
				case "mapValue":
					// Convert map
					if mapMap, ok := val.(map[string]any); ok {
						if fields, ok := mapMap["fields"].(map[string]any); ok {
							result := make(map[string]any)
							for k, v := range fields {
								converted, err := JSONToFirestoreValue(v, client)
								if err != nil {
									return nil, fmt.Errorf("map field %q: %w", k, err)
								}
								result[k] = converted
							}
							return result, nil
						}
					}
					return nil, fmt.Errorf("invalid map value format")
				case "referenceValue":
					// Convert to DocumentRef if client is provided
					if strVal, ok := val.(string); ok {
						if client != nil && isValidDocumentPath(strVal) {
							return client.Doc(strVal), nil
						}
						// Return the path as string if no client or invalid path
						return strVal, nil
					}
					return nil, fmt.Errorf("reference value must be a string")
				default:
					// If not a typed value, treat as regular map
					return convertPlainMap(v, client)
				}
			}
		}
		// Regular map without type annotation
		return convertPlainMap(v, client)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Send maps as {"fields": {"key": <value>, ...}}
  2. Ensure the outer value is a JSON object with a fields member
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/tools/firestore/util/converter.go:137 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/ab33294b625dcd3f. Report an issue: GitHub.