mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: improve apply_diff error messages with clear examples
- Added applyDiffMissingParamError function to provide tool-specific error messages - Shows relevant examples for both legacy and new apply_diff formats - Includes helpful hints about exact content matching and using read_file tool - Addresses issue #9113 for better error clarity when apply_diff validation fails
This commit is contained in:
parent
e98f4b9057
commit
1afef7d61d
2 changed files with 60 additions and 13 deletions
|
|
@ -36,6 +36,64 @@ Otherwise, if you have not completed the task and do not need additional informa
|
|||
missingToolParameterError: (paramName: string) =>
|
||||
`Missing value for required parameter '${paramName}'. Please retry with complete response.\n\n${toolUseInstructionsReminder}`,
|
||||
|
||||
applyDiffMissingParamError: (isLegacyMode: boolean) => {
|
||||
const errorType = isLegacyMode
|
||||
? "legacy 'path' and 'diff' (must be valid and non-empty)"
|
||||
: "args (must contain at least one valid file element)"
|
||||
|
||||
const example = isLegacyMode
|
||||
? `# Example for apply_diff (legacy mode):
|
||||
|
||||
<apply_diff>
|
||||
<path>src/example.js</path>
|
||||
<diff>
|
||||
<<<<<<< SEARCH
|
||||
:start_line:10
|
||||
-------
|
||||
const oldFunction = () => {
|
||||
return "old value";
|
||||
};
|
||||
=======
|
||||
const newFunction = () => {
|
||||
return "new value";
|
||||
};
|
||||
>>>>>>> REPLACE
|
||||
</diff>
|
||||
</apply_diff>`
|
||||
: `# Example for apply_diff:
|
||||
|
||||
<apply_diff>
|
||||
<args>
|
||||
<file>
|
||||
<path>src/example.js</path>
|
||||
<diff>
|
||||
<content>
|
||||
<<<<<<< SEARCH
|
||||
:start_line:10
|
||||
-------
|
||||
const oldFunction = () => {
|
||||
return "old value";
|
||||
};
|
||||
=======
|
||||
const newFunction = () => {
|
||||
return "new value";
|
||||
};
|
||||
>>>>>>> REPLACE
|
||||
</content>
|
||||
<start_line>10</start_line>
|
||||
</diff>
|
||||
</file>
|
||||
</args>
|
||||
</apply_diff>`
|
||||
|
||||
return `Missing value for required parameter '${errorType}'. Please retry with complete response.
|
||||
|
||||
${example}
|
||||
|
||||
Note: The search content must match the file content EXACTLY, including whitespace and indentation.
|
||||
Use the read_file tool first if you need to verify the current file content.`
|
||||
},
|
||||
|
||||
lineCountTruncationError: (actualLineCount: number, isNewFile: boolean, diffStrategyEnabled: boolean = false) => {
|
||||
const truncationMessage = `Note: Your response may have been truncated because it exceeded your output limit. You wrote ${actualLineCount} lines of content, but the line_count parameter was either missing or not included in your response.`
|
||||
|
||||
|
|
|
|||
|
|
@ -192,11 +192,7 @@ Original error: ${errorMessage}`
|
|||
// Neither new XML args nor old path/diff params are sufficient
|
||||
cline.consecutiveMistakeCount++
|
||||
cline.recordToolError("apply_diff")
|
||||
const errorMsg = await cline.sayAndCreateMissingParamError(
|
||||
"apply_diff",
|
||||
"args (or legacy 'path' and 'diff' parameters)",
|
||||
)
|
||||
pushToolResult(errorMsg)
|
||||
pushToolResult(formatResponse.applyDiffMissingParamError(false))
|
||||
cline.processQueuedMessages()
|
||||
return
|
||||
}
|
||||
|
|
@ -205,14 +201,7 @@ Original error: ${errorMessage}`
|
|||
if (Object.keys(operationsMap).length === 0) {
|
||||
cline.consecutiveMistakeCount++
|
||||
cline.recordToolError("apply_diff")
|
||||
pushToolResult(
|
||||
await cline.sayAndCreateMissingParamError(
|
||||
"apply_diff",
|
||||
usingLegacyParams
|
||||
? "legacy 'path' and 'diff' (must be valid and non-empty)"
|
||||
: "args (must contain at least one valid file element)",
|
||||
),
|
||||
)
|
||||
pushToolResult(formatResponse.applyDiffMissingParamError(usingLegacyParams))
|
||||
cline.processQueuedMessages()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue