{"record":{"id":"ff93cb5e58db9c9f","repo":"deepseek-ai/deepseek-harness","slug":"harness-handle-method-fn-needs-a-non-empty-strin","errorCode":null,"errorMessage":"harness.handle(method, fn) needs a non-empty string method name","messagePattern":"harness\\.handle\\(method, fn\\) needs a non-empty string method name","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/extensions/cordis-host-runner/src/guard.ts","lineNumber":606,"sourceCode":"  return markDynamicTool({\n    ...tool,\n    parameters,\n  })\n}\n\n/**\n * Normalize one `harness.handle` registration at the sandbox boundary: the\n * method name must be a non-empty string and the handler a function whose\n * result is host-materialized through the same cross-realm JSON clone as tool\n * `execute` returns (a VM-realm object would otherwise escape the wire's\n * plain-object contract).\n * @param method - handler name the package's browser half calls through `host.call`.\n * @param fn - sandbox handler receiving the wire-decoded JSON arguments.\n * @returns the validated name and the clone-wrapped handler.\n */\nexport function normalizeHandler(method: unknown, fn: unknown): { method: string; handler: (args: unknown) => Promise<unknown> } {\n  if (typeof method !== 'string' || method.length === 0) {\n    throw new Error('harness.handle(method, fn) needs a non-empty string method name')\n  }\n  if (typeof fn !== 'function') {\n    throw new Error(`harness.handle(\"${method}\") needs a handler function as its second argument`)\n  }\n  const rawHandler = fn as (args: unknown) => unknown\n  return {\n    method,\n    handler: async (args: unknown): Promise<unknown> =>\n      cloneJson(await rawHandler(args), `harness.handle(\"${method}\") result`),\n  }\n}\n\n/**\n * The `harness.registerTool` handed into the sandbox: registers a\n * marker-verified dynamic tool on the given context's registry.\n * @param ctx - the (guarded) context whose `tools` service receives the tool.\n * @param tool - a definition produced by {@link sandboxDefineTool}; anything else is rejected.\n * @returns the registry disposer for the registration.","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/extensions/cordis-host-runner/src/guard.ts#L588-L624","documentation":"Error \"harness.handle(method, fn) needs a non-empty string method name\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/extensions/cordis-host-runner/src/guard.ts:606 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}