{"record":{"id":"455b00172dd4194a","repo":"googleapis/mcp-toolbox","slug":"invalid-number-item-found-in-array-for-para","errorCode":null,"errorMessage":"Invalid number \"${item}\" found in array for ${paramName} at index ${index}.","messagePattern":"Invalid number \"(.+?)\" found in array for (.+?) at index (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"internal/server/static/js/runTool.js","lineNumber":146,"sourceCode":"function 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:\n                return item;\n        }\n    });\n}\n\n/**\n * Displays the results from the tool run in the response area.\n */\nexport function displayResults(results, responseArea, prettify) {\n    if (results === null || results === undefined) {\n        return;\n    }","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/server/static/js/runTool.js#L128-L164","documentation":"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.","triggerScenarios":"Passing {\"referenceValue\": {\"path\": \"users/u1\"}} (object), {\"referenceValue\": 12345}, or {\"referenceValue\": null}.","commonSituations":"Clients serialize reference objects from another SDK instead of the raw path string; template engines emit null for unset references.","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."],"exampleFix":"// before\n{\"referenceValue\": {\"path\": \"users/u1\"}}\n// after\n{\"referenceValue\": \"users/u1\"}","handlingStrategy":"type-guard","validationCode":"func checkReferencePayload(v any) error { if _, ok := v.(string); !ok { return fmt.Errorf(\"referenceValue payload must be a string, got %T\", v) }; return nil }","typeGuard":"func asReferenceString(v any) (string, bool) { s, ok := v.(string); return s, ok }","tryCatchPattern":"if _, err := JSONToFirestoreValue(val, client); err != nil {\n    if strings.Contains(err.Error(), \"reference value must be a string\") { /* replace object/number payload with the path string */ }\n}","preventionTips":["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"],"tags":["firestore","reference","type-mismatch"],"backgroundTag":"wrong-json-type-for-field","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"}