googleapis/mcp-toolbox · error

array item

Error message

array item %d: %w

What it means

Recursive wrap in JSONToFirestoreValue for arrayValue: converting one element of the array failed; the index and the wrapped error identify the offending element and its specific problem.

Solutions

  1. Fix the array element named by the index according to the wrapped error
  2. Ensure every element carries a valid Firestore value tag
Defensive patterns

Strategy: try-catch

When it happens

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

Appendix: source

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

						lat, latOk := geoMap["latitude"].(float64)
						lng, lngOk := geoMap["longitude"].(float64)
						if latOk && lngOk {
							return &latlng.LatLng{
								Latitude:  lat,
								Longitude: lng,
							}, nil
						}
					}
					return nil, fmt.Errorf("invalid geopoint value format")
				case "arrayValue":
					// Convert array
					if arrayMap, ok := val.(map[string]any); ok {
						if values, ok := arrayMap["values"].([]any); ok {
							result := make([]any, len(values))
							for i, item := range values {
								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

View on GitHub (pinned to 8cc6e09de2)