{"record":{"id":"5fdb599e2ec9c9c4","repo":"can1357/oh-my-pi","slug":"no-files-were-modified","errorCode":null,"errorMessage":"No files were modified.","messagePattern":"No files were modified\\.","errorType":"exception","errorClass":"ApplyPatchError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/edit/apply-patch/index.ts","lineNumber":41,"sourceCode":"\t/** Affected file paths grouped by operation, for the §9.1 summary. */\n\taffected: {\n\t\tadded: string[];\n\t\tmodified: string[];\n\t\tdeleted: string[];\n\t};\n}\n\n/**\n * Apply a full Codex `*** Begin Patch` envelope.\n *\n * Note: renames are reported under `modified` with the original path (spec\n * §9.1), not as a delete + add.\n */\nexport async function applyCodexPatch(patchText: string, options: ApplyPatchOptions): Promise<ApplyCodexPatchResult> {\n\tconst hunks = parseApplyPatch(patchText);\n\n\tif (hunks.length === 0) {\n\t\tthrow new ApplyPatchError(\"No files were modified.\");\n\t}\n\n\tconst results: ApplyPatchResult[] = [];\n\tconst affected = {\n\t\tadded: [] as string[],\n\t\tmodified: [] as string[],\n\t\tdeleted: [] as string[],\n\t};\n\n\tfor (const hunk of hunks) {\n\t\tconst result = await applyPatch(hunk, options);\n\t\tresults.push(result);\n\t\trecordAffected(affected, hunk, result);\n\t}\n\n\treturn { results, affected };\n}\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/edit/apply-patch/index.ts#L23-L59","documentation":"applyCodexPatch parses the patch into hunks and refuses to proceed when the parse yields zero hunks — i.e. the patch contains no Add/Delete/Update File operations. It throws ApplyPatchError rather than silently succeeding with 'nothing done'.","triggerScenarios":"Calling applyCodexPatch(applyLegacyPatch result path) with text that parses to an empty hunk list: only the Begin/End markers, only comments, or whitespace/blank content inside the markers.","commonSituations":"An LLM/agent emitted a patch with no file operations; the patch body was stripped by upstream processing; a template rendered only the wrapper markers; passing an already-applied or truncated patch.","solutions":["Inspect the patch text: ensure it contains at least one '*** Add File:', '*** Delete File:', or '*** Update File:' hunk between the markers","If the patch came from a model, re-prompt — the operation produced no changes","Treat 'no files were modified' as expected and skip calling applyCodexPatch when the patch body is empty (pre-validate)"],"exampleFix":"// before\nawait applyCodexPatch(patchText); // throws when patch has no hunks\n// after\nif (parseApplyPatch(patchText).length === 0) {\n\treturn { applied: false, reason: 'patch contained no file operations' };\n}\nawait applyCodexPatch(patchText);","handlingStrategy":"validation","validationCode":"if (parseApplyPatch(patchText).length === 0) {\n\tthrow new SkipOperation('patch has no file operations');\n}","typeGuard":null,"tryCatchPattern":"try {\n\tawait applyCodexPatch(patchText, opts);\n} catch (err) {\n\tif (err instanceof ApplyPatchError && err.message === 'No files were modified.') {\n\t\treturn { applied: false };\n\t}\n\tthrow err;\n}","preventionTips":["Verify patches contain at least one hunk before applying","Sanitize model output before parsing","Log the raw patch text when application fails"],"tags":["patch","apply-patch","parser","empty-input"],"backgroundTag":"empty-patch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}