{"record":{"id":"62a2410f8e943cee","repo":"dotnet/runtime","slug":"args-must-be-an-object-but-got-json-stringify-a","errorCode":null,"errorMessage":"args must be an object, but got ${JSON.stringify(args)}","messagePattern":"args must be an object, but got (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/debug.ts","lineNumber":138,"sourceCode":"}\n\nexport function mono_wasm_change_debugger_log_level (level: number): void {\n    forceThreadMemoryViewRefresh();\n    cwraps.mono_wasm_change_debugger_log_level(level);\n}\n\n/**\n * Raises an event for the debug proxy\n */\nexport function mono_wasm_raise_debug_event (event: WasmEvent, args = {}): void {\n    if (typeof event !== \"object\")\n        throw new Error(`event must be an object, but got ${JSON.stringify(event)}`);\n\n    if (event.eventName === undefined)\n        throw new Error(`event.eventName is a required parameter, in event: ${JSON.stringify(event)}`);\n\n    if (typeof args !== \"object\")\n        throw new Error(`args must be an object, but got ${JSON.stringify(args)}`);\n\n    // eslint-disable-next-line no-console\n    console.debug(\"mono_wasm_debug_event_raised:aef14bca-5519-4dfe-b35a-f867abc123ae\", JSON.stringify(event), JSON.stringify(args));\n}\n\nexport function mono_wasm_wait_for_debugger (): Promise<void> {\n    return new Promise<void>((resolve) => {\n        const interval = setInterval(() => {\n            if (runtimeHelpers.waitForDebugger != 1) {\n                return;\n            }\n            clearInterval(interval);\n            resolve();\n        }, 100);\n    });\n}\n\nexport function mono_wasm_debugger_attached (): void {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/debug.ts#L120-L156","documentation":"Thrown by mono_wasm_raise_debug_event() in debug.ts when the `args` parameter (second argument, defaulting to {}) is not of type 'object'. args carries extra event arguments forwarded to the proxy; passing a primitive is a contract violation. The default {} means most callers never hit this; it only fires when a caller explicitly passes a non-object.","triggerScenarios":"Calling mono_wasm_raise_debug_event(event, 'someString') or (event, 5). A refactor passing a payload value where the args object was expected.","commonSituations":"Argument-position confusion: passing the payload as the second arg instead of folding it into the event object. Fork code that supplies args positionally.","solutions":["Omit args (use the default {}) unless you need extra forwarded arguments.","If you pass args, pass an object literal: { key: value }.","Re-check argument order: (event, args)."],"exampleFix":"// before\nmono_wasm_raise_debug_event(event, bpId);  // bpId is a number\n\n// after\nmono_wasm_raise_debug_event(event, { bpId });\n// or simply omit it\nmono_wasm_raise_debug_event(event);","handlingStrategy":"type-guard","validationCode":"function raise(event: WasmEvent, args?: unknown) {\n  if (args !== undefined && (args === null || typeof args !== 'object' || Array.isArray(args) === false ? false : true) === false && typeof args !== 'object') {\n    throw new TypeError('args must be an object');\n  }\n  mono_wasm_raise_debug_event(event, (args ?? {}) as any);\n}","typeGuard":"function isPlainObject(v: unknown): v is Record<string, unknown> {\n  return v !== null && typeof v === \"object\" && !Array.isArray(v);\n}","tryCatchPattern":"null","preventionTips":["Omit args unless you need it (default is {}).","Keep argument order straight: (event, args)."],"tags":["debugger","events","contracts","type-error"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}