{"record":{"id":"7113305b262d9747","repo":"can1357/oh-my-pi","slug":"error-message-copy-ready-corrected-payload-r","errorCode":null,"errorMessage":"${error.message}\nCopy-ready corrected payload:\n${retry}","messagePattern":"(.+?)\nCopy-ready corrected payload:\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/edit/sloppy.ts","lineNumber":3551,"sourceCode":"\t\t\t? `\\nYour rewrite normalized to text identical to these lines. Indentation-only changes are applied verbatim; adjust the authored REWRITE if another whitespace change was intended.\\nCurrent file content near the closest match (no re-read needed):\\n${numberedPreview(preview.content, preview.offset)}`\n\t\t\t: \"\";\n\t\tthrow new Error(base + grounding + (hint ? `\\n${hint}` : \"\"));\n\t};\n\n\tlet operations: Operation[];\n\ttry {\n\t\toperations = parseOperations(input, content);\n\t} catch (error) {\n\t\tif (!(error instanceof Error)) throw error;\n\t\t// A parse error that already carries a copy-ready payload (e.g. the\n\t\t// fill-in skeleton) must not be followed by an echo of the broken input.\n\t\tif (error.message.includes(\"Copy-ready corrected payload\")) throw error;\n\t\tconst normalizedPayload = normalizeInput(input);\n\t\tconst retry =\n\t\t\tparseOpener(normalizedPayload.split(\"\\n\")[0] ?? \"\") === false\n\t\t\t\t? `${OPENER}\\n${normalizedPayload}`\n\t\t\t\t: normalizedPayload;\n\t\tthrow new Error(`${error.message}\\nCopy-ready corrected payload:\\n${retry}`);\n\t}\n\tconst removedByOperation: Array<string | undefined> = [];\n\tconst planned: PlannedEdit[] = [];\n\tconst deletionNotes = new Map<number, string>();\n\tconst recoveryNotes: string[] = [];\n\tlet lastMatchOffset = 0;\n\t// Ambiguous ops defer once: after every sibling plans its edit, their spans\n\t// exclude already-claimed candidates and a genuinely unique match survives.\n\tconst queue = operations.map((_, order) => order);\n\tconst deferredAmbiguous = new Set<number>();\n\tfor (let cursor = 0; cursor < queue.length; cursor++) {\n\t\tconst index = queue[cursor];\n\t\tconst operationNumber = index + 1;\n\t\tconst parsedNote = operations[index].recoveryNote;\n\t\tif (parsedNote !== undefined) recoveryNotes.push(parsedNote);\n\t\tlet located: { operation: Operation; pattern: ParsedPattern; candidates: Candidate[] };\n\t\ttry {\n\t\t\tlocated = locateWithEchoRecovery(","sourceCodeStart":3533,"sourceCodeEnd":3569,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/edit/sloppy.ts#L3533-L3569","documentation":"When payload parsing fails inside applySloppyEdit, the library catches the parse error and re-throws it with a 'Copy-ready corrected payload:' section appended. The appended payload is the normalized input, prefixed with the opener line if the first line lacked one, so the caller can fix and retry with a syntactically valid payload directly. If the message already carries this section it is re-thrown untouched to avoid double augmentation.","triggerScenarios":"parseOperations throws (malformed opener, bad markers, malformed operations) while calling applySloppyEdit; the catch block at sloppy.ts:3551 augments any error message not already containing 'Copy-ready corrected payload'.","commonSituations":"Missing or malformed opener on the first line; stray whitespace/normalization differences; model payloads with slightly wrong marker alphabet; hand-written payloads missing the separator lines.","solutions":["Take the copy-ready payload from the error message, fix the reported syntax problem, and resubmit it.","Ensure the first line is a valid opener (e.g. » or the variant's opener); the normalization only prepends it when the opener parses as false.","Re-emit the payload in full with correct markers and separators rather than patching fragments."],"exampleFix":"// before (missing opener)\nconst x = 1\n====\nconst x = 2\n\n// after (opener added)\n»\nconst x = 1\n====\nconst x = 2","handlingStrategy":"try-catch","validationCode":"function assertPayloadShape(payload: string, opener: RegExp) {\n  if (!opener.test(payload.split(\"\\n\")[0] ?? \"\"))\n    throw new Error(\"payload must start with a valid opener line\");\n  if (!payload.includes(\"====\")) throw new Error(\"payload must contain PATTERN/REWRITE separators\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  applySloppyEdit(payload);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"Copy-ready corrected payload:\")) {\n    const corrected = err.message.split(\"Copy-ready corrected payload:\\n\")[1];\n    applySloppyEdit(corrected);\n  } else throw err;\n}","preventionTips":["Always start payloads with the correct opener line for the active variant","Take the 'Copy-ready corrected payload' from the error verbatim and edit from there","Validate separators and marker alphabet before calling apply"],"tags":["edit-dsl","payload-parse","error-augmentation"],"backgroundTag":"invalid-edit-payload","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}