googleapis/mcp-toolbox · error · Error
Invalid number "${item}" found in array for ${paramName} at
Error message
Invalid number "${item}" found in array for ${paramName} at index ${index}. What it means
A "referenceValue" must carry a string payload (the document path). If the value under "referenceValue" is any other JSON type, this error is returned. Valid string references are converted to a *firestore.DocumentRef when a client is provided, otherwise returned as the path string.
Source
Thrown at internal/server/static/js/runTool.js:146
function parseArrayParameter(rawValue, valueType, paramName) {
const ELEMENT_TYPE = valueType.substring(6, valueType.length - 1);
let parsedArray;
try {
parsedArray = JSON.parse(rawValue);
} catch (e) {
throw new Error(`Invalid JSON format for ${paramName}. Expected an array. ${e.message}`);
}
if (!Array.isArray(parsedArray)) {
throw new Error(`Input for ${paramName} must be a JSON array (e.g., ["a", "b"]).`);
}
return parsedArray.map((item, index) => {
switch (ELEMENT_TYPE) {
case 'number':
const NUM = Number(item);
if (isNaN(NUM)) {
throw new Error(`Invalid number "${item}" found in array for ${paramName} at index ${index}.`);
}
return NUM;
case 'boolean':
return item === true || String(item).toLowerCase() === 'true';
case 'string':
default:
return item;
}
});
}
/**
* Displays the results from the tool run in the response area.
*/
export function displayResults(results, responseArea, prettify) {
if (results === null || results === undefined) {
return;
}View on GitHub (pinned to 8cc6e09de2)
Solutions
- Provide the reference as a plain document path string, e.g. "projects/p/databases/(default)/documents/users/u1" or "users/u1".
- Pass a non-nil firestore client if you want automatic conversion to a *firestore.DocumentRef.
- Omit the field entirely if the reference is unset.
Example fix
// before
{"referenceValue": {"path": "users/u1"}}
// after
{"referenceValue": "users/u1"} Defensive patterns
Strategy: type-guard
Validate before calling
func checkReferencePayload(v any) error { if _, ok := v.(string); !ok { return fmt.Errorf("referenceValue payload must be a string, got %T", v) }; return nil } Type guard
func asReferenceString(v any) (string, bool) { s, ok := v.(string); return s, ok } Try / catch
if _, err := JSONToFirestoreValue(val, client); err != nil {
if strings.Contains(err.Error(), "reference value must be a string") { /* replace object/number payload with the path string */ }
} Prevention
- Store references as plain document path strings
- Pass a non-nil firestore client to get *firestore.DocumentRef conversion
- Reject reference objects from other SDKs at the boundary
When it happens
Trigger: Passing {"referenceValue": {"path": "users/u1"}} (object), {"referenceValue": 12345}, or {"referenceValue": null}.
Common situations: Clients serialize reference objects from another SDK instead of the raw path string; template engines emit null for unset references.
Related errors
- Toolbox binary not found
- HTTP error! status: ${response.status}
- Invalid number input for ${NAME}: ${RAW_VALUE}
- HTTP error ${response.status}: ${errorBody}
- Invalid JSON format for ${paramName}. Expected an array. ${e
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/455b00172dd4194a.
Report an issue: GitHub.