{"record":{"id":"02c255840aae8c13","repo":"dotnet/runtime","slug":"arguments-should-be-an-array-but-was-request","errorCode":null,"errorMessage":"\"arguments\" should be an array, but was ${request.arguments}","messagePattern":"\"arguments\" should be an array, but was (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/debug.ts","lineNumber":228,"sourceCode":"                        return prop.value;\n                    },\n                    set: function (newValue) {\n                        mono_wasm_send_dbg_command_with_parms(prop.set.id, prop.set.commandSet, prop.set.command, prop.set.buffer, prop.set.length, prop.set.valtype, newValue); return true;\n                    }\n                }\n            );\n        } else {\n            proxy[prop.name] = prop.value;\n        }\n    });\n    return proxy;\n}\n\nexport function mono_wasm_call_function_on (request: CallRequest): CFOResponse {\n    forceThreadMemoryViewRefresh();\n\n    if (request.arguments != undefined && !Array.isArray(request.arguments))\n        throw new Error(`\"arguments\" should be an array, but was ${request.arguments}`);\n\n    const objId = request.objectId;\n    const details = request.details;\n    let proxy: any = {};\n\n    if (objId.startsWith(\"dotnet:cfo_res:\")) {\n        if (objId in _call_function_res_cache)\n            proxy = _call_function_res_cache[objId];\n        else\n            throw new Error(`Unknown object id ${objId}`);\n    } else {\n        proxy = _create_proxy_from_object_id(objId, details);\n    }\n\n    const fn_args = request.arguments != undefined ? request.arguments.map(a => JSON.stringify(a.value)) : [];\n\n    const fn_body_template = `const fn = ${request.functionDeclaration}; return fn.apply(proxy, [${fn_args}]);`;\n    const fn_defn = new Function(\"proxy\", fn_body_template);","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/debug.ts#L210-L246","documentation":"Thrown by mono_wasm_call_function_on() in debug.ts when request.arguments is defined but is not an Array. This function implements the CDP Runtime.callFunctionOn against .NET objects: arguments must be an array of { value } entries (type CallArgs[]) so they can be JSON.stringify'd into the generated function body. Passing an object or single value instead of an array breaks the .map in the function body construction.","triggerScenarios":"The DevTools/CDP client sending arguments as an object ({0: ...}) or a single value rather than an array. A custom debugger integration building a CallRequest with request.arguments = someObject.","commonSituations":"A non-standard CDP client or test harness mis-serializing arguments. Forked debugger glue that constructs CallRequest manually and forgets the array wrapper.","solutions":["Send arguments as an array: request.arguments = [{ value: JSON.stringify(v) }, ...].","If you have no arguments, set request.arguments = undefined (the check skips undefined).","Validate with Array.isArray(request.arguments) before calling."],"exampleFix":"// before\n{ objectId, arguments: { value: '\"42\"' } }\n\n// after\n{ objectId, arguments: [{ value: '\"42\"' }] }","handlingStrategy":"validation","validationCode":"function callFunctionOn(request: CallRequest) {\n  if (request.arguments !== undefined && !Array.isArray(request.arguments)) {\n    throw new TypeError('request.arguments must be an array of { value } or undefined');\n  }\n  return mono_wasm_call_function_on(request);\n}","typeGuard":"function isValidCallArgs(a: unknown): a is Array<{ value: string }> | undefined {\n  return a === undefined || (Array.isArray(a) && a.every(x => x != null && typeof x === 'object' && 'value' in x));\n}","tryCatchPattern":"null","preventionTips":["Pass arguments as an array of { value } entries.","Use undefined (not null) when there are no arguments."],"tags":["debugger","cdp","contracts","validation"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}