googleapis/mcp-toolbox · error · Error
Invalid JSON format for ${paramName}. Expected an array. ${e
Error message
Invalid JSON format for ${paramName}. Expected an array. ${e.message} What it means
When converting a "mapValue", each field is recursively converted via JSONToFirestoreValue. A failure in any field is wrapped as "map field %q: %w" naming the offending key. This is a wrapper error — the root cause is the wrapped inner error.
Source
Thrown at internal/server/static/js/runTool.js:134
updateLastResults(null);
}
}
/**
* Parses and validates a single array parameter from a raw string value.
* @param {string} rawValue The raw string value from FormData.
* @param {string} valueType The full array type string (e.g., "array<number>").
* @param {string} paramName The name of the parameter for error messaging.
* @return {!Array<*>} The parsed array.
* @throws {Error} If parsing or type validation fails.
*/
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:View on GitHub (pinned to 8cc6e09de2)
Solutions
- Check the quoted field name in the message and inspect that field's value.
- Read the wrapped inner error for the actual cause (parse failure, wrong type, etc.).
- Fix the named field's format, then resubmit.
Example fix
// before
{"mapValue": {"fields": {"createdAt": {"timestampValue": "01/01/2024"}}}}
// after
{"mapValue": {"fields": {"createdAt": {"timestampValue": "2024-01-01T00:00:00Z"}}}} Defensive patterns
Strategy: try-catch
Validate before calling
for k, v := range fields {
if _, err := JSONToFirestoreValue(v, client); err != nil { return fmt.Errorf("field %q invalid: %w", k, err) }
} Try / catch
if _, err := JSONToFirestoreValue(mapVal, client); err != nil {
var field string
if n, _ := fmt.Sscanf(err.Error(), "map field %q", &field); n == 1 { /* inspect field */ }
} Prevention
- Validate nested map fields individually before submission
- Keep a schema of allowed typed values per field
- Log the quoted field name from the error to locate the offender
When it happens
Trigger: Passing {"mapValue": {"fields": {"createdAt": {"timestampValue": "bad-date"}}}} where any field inside "fields" fails its own conversion.
Common situations: Nested documents where one field has an invalid timestamp/geopoint; dynamically generated payloads with one bad field.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- /api native endpoints are disabled by default. Please use th
- Invalid number input for ${NAME}: ${RAW_VALUE}
- Input for ${paramName} must be a JSON array (e.g., ["a", "b"
- Toolbox binary not found
- HTTP error! status: ${response.status}
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/49f4942a84ec78ed.
Report an issue: GitHub.