{"record":{"id":"776111ffb80b82d1","repo":"can1357/oh-my-pi","slug":"sloppy-edit-completed-without-a-result","errorCode":null,"errorMessage":"Sloppy edit completed without a result.","messagePattern":"Sloppy edit completed without a result\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/edit/sloppy.ts","lineNumber":4019,"sourceCode":"\t\tawait onApplied?.({ path: entry.absolutePath, prev: entry.rawContent, next: finalContent });\n\t\tconst editResult = createEditResult({\n\t\t\tdisplayPath: entry.path,\n\t\t\tresultPath: entry.absolutePath,\n\t\t\tdiff: diffResult.diff,\n\t\t\tfirstChangedLine: diffResult.firstChangedLine,\n\t\t\tdiagnostics,\n\t\t\toldText: entry.rawContent,\n\t\t\tnewText: finalContent,\n\t\t\tafterPreview: entry.notes,\n\t\t});\n\t\tfirstChangedLine ??= diffResult.firstChangedLine;\n\t\tsingleResult ??= editResult;\n\t\tcontentTexts.push(editResult.text);\n\t\tperFileResults.push(editResult.perFileResult);\n\t}\n\n\tif (!multiFile) {\n\t\tif (!singleResult) throw new Error(\"Sloppy edit completed without a result.\");\n\t\treturn toEditToolResult(singleResult);\n\t}\n\n\treturn createAggregateEditToolResult(\n\t\tjoinEditResultText(contentTexts),\n\t\tcreateAggregateEditDetails({ firstChangedLine, perFileResults }),\n\t);\n}\n","sourceCodeStart":4001,"sourceCodeEnd":4028,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/edit/sloppy.ts#L4001-L4028","documentation":"An internal invariant check in the single-file edit path: after processing all sections the code expects at least one edit result, but singleResult is still undefined. This indicates a logic bug (e.g. the sections list was empty but the code proceeded to the result branch) rather than a user-facing input problem.","triggerScenarios":"Invoking the sloppy edit path in single-file mode where the per-section loop produced no EditResult — effectively a guarded-against internal state, likely from an empty sections array reaching the result aggregation.","commonSituations":"A tool bug: empty section list passed validation but skipped the loop; a regression in the edit plumbing where results were not assigned.","solutions":["Report as a bug; this should be unreachable","Check the tool call actually includes a non-empty sections list","Retry the edit; if reproducible, capture the exact arguments and file a bug report"],"exampleFix":"// before: empty sections reaching single-file result path\nedit({ path, sections: [] })\n// after: guard caller-side with at least one section\nedit({ path, sections: [{ heading, body }] })","handlingStrategy":"try-catch","validationCode":"if (!sections.length) throw new Error('at least one section required');","typeGuard":"null","tryCatchPattern":"try { await editSloppy(args) } catch (e) { if (e.message === 'Sloppy edit completed without a result.') { reportBug(e); } else throw e }","preventionTips":["Always pass a non-empty sections array","Upgrade to latest fix release; this is an invariant bug","Capture repro args if you can trigger it","Report with the exact tool call"],"tags":["internal-invariant","edit-tool","bug"],"backgroundTag":"internal-invariant-violation","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}