{"record":{"id":"49f4942a84ec78ed","repo":"googleapis/mcp-toolbox","slug":"invalid-json-format-for-paramname-expected-an","errorCode":null,"errorMessage":"Invalid JSON format for ${paramName}. Expected an array. ${e.message}","messagePattern":"Invalid JSON format for (.+?)\\. Expected an array\\. (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"internal/server/static/js/runTool.js","lineNumber":134,"sourceCode":"        updateLastResults(null);\n    }\n}\n\n/**\n * Parses and validates a single array parameter from a raw string value.\n * @param {string} rawValue The raw string value from FormData.\n * @param {string} valueType The full array type string (e.g., \"array<number>\").\n * @param {string} paramName The name of the parameter for error messaging.\n * @return {!Array<*>} The parsed array.\n * @throws {Error} If parsing or type validation fails.\n */\nfunction parseArrayParameter(rawValue, valueType, paramName) {\n    const ELEMENT_TYPE = valueType.substring(6, valueType.length - 1);\n    let parsedArray;\n    try {\n        parsedArray = JSON.parse(rawValue);\n    } catch (e) {\n        throw new Error(`Invalid JSON format for ${paramName}. Expected an array. ${e.message}`);\n    }\n\n    if (!Array.isArray(parsedArray)) {\n        throw new Error(`Input for ${paramName} must be a JSON array (e.g., [\"a\", \"b\"]).`);\n    }\n\n    return parsedArray.map((item, index) => {\n        switch (ELEMENT_TYPE) {\n            case 'number':\n                const NUM = Number(item);\n                if (isNaN(NUM)) {\n                    throw new Error(`Invalid number \"${item}\" found in array for ${paramName} at index ${index}.`);\n                }\n                return NUM;\n            case 'boolean':\n                return item === true || String(item).toLowerCase() === 'true';\n            case 'string':\n            default:","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/server/static/js/runTool.js#L116-L152","documentation":"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.","triggerScenarios":"Passing {\"mapValue\": {\"fields\": {\"createdAt\": {\"timestampValue\": \"bad-date\"}}}} where any field inside \"fields\" fails its own conversion.","commonSituations":"Nested documents where one field has an invalid timestamp/geopoint; dynamically generated payloads with one bad field.","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."],"exampleFix":"// before\n{\"mapValue\": {\"fields\": {\"createdAt\": {\"timestampValue\": \"01/01/2024\"}}}}\n// after\n{\"mapValue\": {\"fields\": {\"createdAt\": {\"timestampValue\": \"2024-01-01T00:00:00Z\"}}}}","handlingStrategy":"try-catch","validationCode":"for k, v := range fields {\n    if _, err := JSONToFirestoreValue(v, client); err != nil { return fmt.Errorf(\"field %q invalid: %w\", k, err) }\n}","typeGuard":null,"tryCatchPattern":"if _, err := JSONToFirestoreValue(mapVal, client); err != nil {\n    var field string\n    if n, _ := fmt.Sscanf(err.Error(), \"map field %q\", &field); n == 1 { /* inspect field */ }\n}","preventionTips":["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"],"tags":["firestore","map","error-wrapping"],"backgroundTag":"nested-value-conversion-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}