{"record":{"id":"d8799b299c29c31a","repo":"can1357/oh-my-pi","slug":"data-is-required-for-write-memory","errorCode":null,"errorMessage":"data is required for write_memory","messagePattern":"data is required for write_memory","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/debug.ts","lineNumber":1043,"sourceCode":"\t\t\t\t\tparams.memory_reference,\n\t\t\t\t\tparams.count,\n\t\t\t\t\tparams.offset,\n\t\t\t\t\tcombinedSignal,\n\t\t\t\t\ttimeoutSec * 1000,\n\t\t\t\t);\n\t\t\t\tdetails.snapshot = response.snapshot;\n\t\t\t\tdetails.memoryAddress = response.address;\n\t\t\t\tdetails.memoryData = response.data;\n\t\t\t\tdetails.unreadableBytes = response.unreadableBytes;\n\t\t\t\treturn result.text(formatMemoryRead(response.address, response.data, response.unreadableBytes)).done();\n\t\t\t}\n\t\t\tcase \"write_memory\": {\n\t\t\t\trequireCapability(\"supportsWriteMemoryRequest\", \"memory writes\");\n\t\t\t\tif (!params.memory_reference) {\n\t\t\t\t\tthrow new ToolError(\"memory_reference is required for write_memory\");\n\t\t\t\t}\n\t\t\t\tif (!params.data) {\n\t\t\t\t\tthrow new ToolError(\"data is required for write_memory\");\n\t\t\t\t}\n\t\t\t\tconst response = await dapSessionManager.writeMemory(\n\t\t\t\t\tparams.memory_reference,\n\t\t\t\t\tparams.data,\n\t\t\t\t\tparams.offset,\n\t\t\t\t\tparams.allow_partial,\n\t\t\t\t\tcombinedSignal,\n\t\t\t\t\ttimeoutSec * 1000,\n\t\t\t\t);\n\t\t\t\tdetails.snapshot = response.snapshot;\n\t\t\t\tdetails.bytesWritten = response.bytesWritten;\n\t\t\t\treturn result\n\t\t\t\t\t.text(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"Memory write completed.\",\n\t\t\t\t\t\t\t...(response.bytesWritten !== undefined ? [`Bytes written: ${response.bytesWritten}`] : []),\n\t\t\t\t\t\t\t...(response.offset !== undefined ? [`Offset: ${response.offset}`] : []),\n\t\t\t\t\t\t].join(\"\\n\"),","sourceCodeStart":1025,"sourceCodeEnd":1061,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/debug.ts#L1025-L1061","documentation":"For action=\"write_memory\", params.data carries the bytes to write (after the required memory_reference). When data is absent or empty the tool throws this ToolError before any adapter interaction. Writing zero bytes is not a meaningful DAP writeMemory call, so the tool treats it as a caller mistake.","triggerScenarios":"Calling write_memory with a valid memory_reference but params.data undefined, null, or an empty string — e.g. the payload variable was never populated or the hex string was trimmed to empty.","commonSituations":"Generated tool calls with the payload under a different key (value, bytes, content); pipelines where an earlier encoding step produced an empty string and the empty check was skipped upstream; accidental no-op writes intended to \"probe\" writability.","solutions":["Pass the payload as a non-empty data string (hex-encoded bytes, matching the tool's expected format).","Validate the payload is non-empty before invoking the tool.","Use the correct key: data, not value/bytes/content.","To probe writability, use a real 1–2 byte write or rely on read_memory's unreadableBytes instead of an empty write."],"exampleFix":"// before\nawait debugTool.run({ action: \"write_memory\", memory_reference: ref, data: \"\" });\n// after\nawait debugTool.run({ action: \"write_memory\", memory_reference: ref, data: \"9090\", allow_partial: false });","handlingStrategy":"validation","validationCode":"if (typeof data !== \"string\" || data.length === 0) throw new Error(\"write_memory requires a non-empty hex data payload\");\nif (!/^[0-9a-fA-F]+$/.test(data)) throw new Error(\"data must be a hex string\");","typeGuard":"function hasPayload(p: { data?: string }): p is { data: string } {\n  return typeof p.data === \"string\" && p.data.length > 0;\n}","tryCatchPattern":"try {\n  await debugTool.run({ action: \"write_memory\", memory_reference: ref, data: hex, allow_partial: false });\n} catch (err) {\n  if (err instanceof ToolError && err.message.includes(\"data is required\")) {\n    // inspect the payload encoding step; fix and re-issue the write\n  } else throw err;\n}","preventionTips":["Assert the hex payload is non-empty right after encoding, before invoking the tool.","Standardize on one payload key (data) in any automation that issues writes.","For writability probes, read first (unreadableBytes) instead of attempting empty writes."],"tags":["debugger","dap","parameter-validation","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}