{"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/60108ba66eb7d1d12f595480091b4ad80a24b172/src/mono/browser/runtime/debug.ts#L210-L246","documentation":"Thrown by `mono_wasm_call_function_on` when `request.arguments` is present but is not an array. The CDP-style `Runtime.callFunctionOn` contract requires `arguments` to be an array of `{ value }` entries; an object or single value is rejected.","triggerScenarios":"Calling `mono_wasm_call_function_on(request)` (debug.ts:224) with `request.arguments` set to an object, a string, or a single `{value}` instead of a list. Typical when a caller builds the request from a single argument without wrapping it in `[ ]`.","commonSituations":"Translating a DevTools Protocol payload incorrectly; reusing a request template and assigning a scalar to `arguments`; off-by-one in spreading arguments.","solutions":["Always pass `arguments` as an array, even for a single argument: `[{ value: x }]`.","Omit `arguments` (or set to `undefined`) when calling with zero arguments.","Add a type assertion or runtime check at the call site."],"exampleFix":"// before: single object instead of array\nmono_wasm_call_function_on({ objectId, functionDeclaration: 'fn', arguments: { value: 1 } }); // throws\n\n// after: wrap in an array\nmono_wasm_call_function_on({ objectId, functionDeclaration: 'fn', arguments: [{ value: 1 }] });","handlingStrategy":"type-guard","validationCode":"function callFunctionOnSafe (request) {\n  if (request.arguments !== undefined && !Array.isArray(request.arguments)) {\n    throw new TypeError('request.arguments must be an array');\n  }\n  return mono_wasm_call_function_on(request);\n}","typeGuard":"function isArgumentsArray (v: unknown): v is Array<{ value: unknown }> {\n  return Array.isArray(v) && v.every(a => a !== null && typeof a === 'object' && 'value' in a);\n}","tryCatchPattern":null,"preventionTips":["Always wrap arguments in an array, even for one argument.","Type the request as `{ arguments?: Array<{ value: unknown }> }`.","Omit `arguments` rather than passing `null` when there are none."],"tags":["debugger","validation","cdp","typescript"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}