{"record":{"id":"96ca8602f540a7f4","repo":"can1357/oh-my-pi","slug":"operation-all-operation-operationnumber","errorCode":null,"errorMessage":"${operation.all ? `Operation ${operationNumber} ${OPENER}* found 0 matches in ${path}. ${guidance.reason}` : `Operation ${operationNumber} did not match ${path}. ${guidance.reason}`}\nCurrent file content near the closest match (no re-read needed):\n${numberedPreview(content, guidance.previewOffset)}\nCopy-ready corrected operation:\n${operationPayload(operation, operation.all ? \"*\" : \"\", guidance.correctedPattern)}","messagePattern":"(.+?) (.+?)\\* found 0 matches in (.+?)\\. (.+?)` : `Operation (.+?) did not match (.+?)\\. (.+?)`\\}\nCurrent file content near the closest match \\(no re-read needed\\):\n(.+?)\nCopy-ready corrected operation:\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/edit/sloppy.ts","lineNumber":2510,"sourceCode":"\tif (candidates.length === 1) return [candidates[0]];\n\tif (candidates.length === 0) {\n\t\tconst separated = nonConsecutiveGuidance(content, operation);\n\t\tif (separated) {\n\t\t\tconst replacementGuidance =\n\t\t\t\toperation.rewrite.kind === \"explicit\"\n\t\t\t\t\t? `The REWRITE then replaces the whole span lines ${separated.locations[0]}-${separated.locations.at(-1)}, including the skipped lines — re-emit kept gaps with ${GAP}.`\n\t\t\t\t\t: `The inline replacements then target the whole span lines ${separated.locations[0]}-${separated.locations.at(-1)}, including skipped lines — re-emit kept gaps with ${GAP}.`;\n\t\t\tthrow new Error(\n\t\t\t\t[\n\t\t\t\t\t`Operation ${operationNumber} did not match ${path}: your lines match individually at lines ${separated.locations.join(\", \")} but are not consecutive.`,\n\t\t\t\t\t\"Copy-ready corrected operation:\",\n\t\t\t\t\toperationPayload(operation, operation.all ? \"*\" : \"\", separated.correctedPattern),\n\t\t\t\t\treplacementGuidance,\n\t\t\t\t].join(\"\\n\"),\n\t\t\t);\n\t\t}\n\t\tconst guidance = noMatchGuidance(content, normalized, pattern, operation);\n\t\tthrow new Error(\n\t\t\t[\n\t\t\t\toperation.all\n\t\t\t\t\t? `Operation ${operationNumber} ${OPENER}* found 0 matches in ${path}. ${guidance.reason}`\n\t\t\t\t\t: `Operation ${operationNumber} did not match ${path}. ${guidance.reason}`,\n\t\t\t\t\"Current file content near the closest match (no re-read needed):\",\n\t\t\t\tnumberedPreview(content, guidance.previewOffset),\n\t\t\t\t\"Copy-ready corrected operation:\",\n\t\t\t\toperationPayload(operation, operation.all ? \"*\" : \"\", guidance.correctedPattern),\n\t\t\t\t...(guidance.additionRetry ? [guidance.additionRetry] : []),\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t}\n\t// Outcome-equivalent ambiguity is no ambiguity: when applying the rewrite\n\t// at every candidate yields the same file (deleting either of two identical\n\t// adjacent copies, rewriting interchangeable spans), pick the first.\n\tif (candidates.length <= 4 && operation.desiredState !== true) {\n\t\tconst rewriteOf = operation.rewrite;\n\t\tconst outcomes = new Set(","sourceCodeStart":2492,"sourceCodeEnd":2528,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/edit/sloppy.ts#L2492-L2528","documentation":"The generic no-match failure: after all fallback strategies the pattern did not match anywhere in the file. The library throws with a diagnostic reason (`guidance.reason`), a numbered preview of the file content nearest the closest match (so no re-read is needed), and a copy-ready corrected operation pattern.","triggerScenarios":"Any sloppy edit operation whose pattern has zero matches after raw, punctuation-tolerant, and literal-fallback passes — wrong content, wrong indentation, stale file view, or a pattern referencing code that does not exist. With `operation.all` set, the message reads \"found 0 matches\" instead of \"did not match\".","commonSituations":"File was modified (by another tool, linter, or prior edit) since it was last read; typos in identifiers or string literals; wrong indentation depth; targeting a different file than the one containing the code; model/agent hallucinating the region content.","solutions":["Read the numbered preview embedded in the error — it shows the closest region without re-reading the file — and correct the pattern from it.","Use the copy-ready corrected operation included in the error message.","Re-read the current file region and rebuild the pattern byte-for-byte.","Verify the edit targets the correct file path."],"exampleFix":"// before\nconst pattern = \"const total = computeTotl(items);\"; // typo\n// after\nconst pattern = \"const total = computeTotal(items);\";","handlingStrategy":"try-catch","validationCode":"// Confirm the primary anchor line exists in a freshly-read file before applying:\nconst content = await Bun.file(path).text();\nif (!content.includes(primaryAnchorLine)) {\n  throw new Error(`anchor not found in ${path}; refresh pattern from the file`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await applySloppyEdit({ path, pattern });\n} catch (err) {\n  if (err instanceof Error && (err.message.includes(\"did not match\") || err.message.includes(\"found 0 matches\"))) {\n    // error embeds a numbered preview of the nearest region and a corrected\n    // pattern — re-read that region, rebuild, retry once\n    return rebuildPatternFromPreviewAndRetry(err.message);\n  }\n  throw err;\n}","preventionTips":["Always re-read the file (or use the error's embedded preview) before retrying a no-match.","Check for typos in identifiers and string literals in the pattern.","Confirm the edit targets the correct file path.","Assume the file may have changed since your last read; patterns must be rebuilt from current content."],"tags":["edit-pattern","matching","no-match"],"backgroundTag":"edit-pattern-no-match","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}