Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 9, 2025

Summary

This PR improves error handling and messaging when the read_file tool encounters empty or whitespace-only path elements in XML arguments.

Problem

Users were receiving a confusing error message "Missing value for required parameter 'path'" when:

  • The path element was empty (<path></path>)
  • The path element contained only whitespace (<path> </path>)
  • The path element was self-closing (<path/>)

This was particularly confusing because the XML structure appeared correct, but the path value was being treated as missing after trimming.

Solution

  • Added explicit checking for empty or whitespace-only paths
  • Provides a clear, specific error message: "All file paths are empty or missing. Please provide valid file paths in the elements."
  • Added comprehensive tests to verify the fix works correctly

Related Issue

Fixes #7664

Testing

  • Added new test file src/core/tools/__tests__/readFileTool-empty-path.spec.ts with tests for various empty path scenarios
  • Added comprehensive XML parsing tests in src/utils/__tests__/xml-whitespace.spec.ts
  • Added tests for assistant message parsing in src/core/assistant-message/__tests__/parseAssistantMessageV2-issue7664.spec.ts
  • All existing tests continue to pass

Note

While investigating this issue, I discovered that the specific problem reported by @juliettefournier-econ was actually due to the AI assistant (Grok Code Fast) using an invalid line_range parameter that doesn't exist for the read_file tool. However, this PR still provides value by improving error messages for empty path scenarios, which will help users debug similar issues more easily.


Important

Improves error handling in readFileTool for empty paths, providing specific error messages and adding comprehensive tests.

  • Behavior:
    • Improves error handling in readFileTool for empty or whitespace-only <path> elements in XML arguments.
    • Provides specific error message: "All file paths are empty or missing. Please provide valid file paths in the elements."
  • Testing:
    • Adds readFileTool-empty-path.spec.ts to test error handling for empty paths.
    • Adds xml-whitespace.spec.ts to test XML parsing with various whitespace scenarios.
    • Adds parseAssistantMessageV2-issue7664.spec.ts to test handling of malformed XML structures.
  • Misc:

This description was created by Ellipsis for 11d7d67. You can customize this summary. It will automatically update as commits are pushed.

- Added better error handling for empty or whitespace-only path elements
- Shows clear error message 'All file paths are empty or missing' instead of generic 'Missing value for required parameter'
- Added comprehensive tests for XML parsing with whitespace and empty paths
- Fixes issue #7664 where users were confused by misleading error messages
@roomote roomote bot requested review from cte and mrubens as code owners September 9, 2025 02:39
@roomote roomote bot requested a review from jr as a code owner September 9, 2025 02:39
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. bug Something isn't working labels Sep 9, 2025

// If all paths were empty, provide a more specific error
if (emptyPathCount > 0 && fileEntries.length === 0) {
const errorMessage = `All file paths are empty or missing. Please provide valid file paths in the <path> elements.`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logic correctly detects empty/whitespace-only path elements and provides a clear error. Consider using the i18n translation function (e.g., t(...)) for the error message (currently hardcoded) so that user‐facing text remains localizable.

Suggested change
const errorMessage = `All file paths are empty or missing. Please provide valid file paths in the <path> elements.`
const errorMessage = t("tools:readFile.allPathsEmpty")

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed my own code and found it surprisingly coherent. Must be a bug in my review algorithm.

}

// If all paths were empty, provide a more specific error
if (emptyPathCount > 0 && fileEntries.length === 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? The code tracks both emptyPathCount and totalFileCount, but the condition only checks emptyPathCount > 0. Could we simplify this to just check if fileEntries.length === 0 after processing all files? The current logic works but seems more complex than necessary.

totalFileCount++

// Check for empty or whitespace-only paths
if (!file.path || (typeof file.path === "string" && file.path.trim() === "")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting this empty path checking logic into a small helper function like isEmptyPath(path) for better readability and reusability:

Suggested change
if (!file.path || (typeof file.path === "string" && file.path.trim() === "")) {
const isEmptyPath = (path: any): boolean => !path || (typeof path === "string" && path.trim() === "");
// Check for empty or whitespace-only paths
if (isEmptyPath(file.path)) {

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 9, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 9, 2025
@daniel-lxs daniel-lxs closed this Sep 9, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 9, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Roo is having trouble - path parameter not provided - Roo XML parser should handle spaces between XML tags

4 participants