googleapis/mcp-toolbox · error

map field %q: %w

Error message

map field %q: %w

What it means

Recursive wrap in JSONToFirestoreValue for mapValue: converting one field of the nested map failed; the field name and wrapped error identify the offending entry.

Source

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

								converted, err := JSONToFirestoreValue(item, client)
								if err != nil {
									return nil, fmt.Errorf("array item %d: %w", i, err)
								}
								result[i] = converted
							}
							return result, nil
						}
					}
					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:

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Fix the named map field according to the wrapped error
  2. Ensure every nested value carries a valid Firestore value tag
Defensive patterns

Strategy: try-catch

When it happens

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