Skip to content

fix: throw InvalidOperationException when MarkItDownMcpReader encounters IsError. - #7627

Open
aaleemsolutions wants to merge 2 commits into
dotnet:mainfrom
aaleemsolutions:fix/markitdown-mcp-error-handling
Open

fix: throw InvalidOperationException when MarkItDownMcpReader encounters IsError.#7627
aaleemsolutions wants to merge 2 commits into
dotnet:mainfrom
aaleemsolutions:fix/markitdown-mcp-error-handling

Conversation

@aaleemsolutions

@aaleemsolutions aaleemsolutions commented Jul 14, 2026

Copy link
Copy Markdown

This PR resolves an issue where MarkItDownMcpReader silently ignores tool errors during document conversion.

Related Issues
Closes #7618

Microsoft Reviewers: Open in CodeFlow

@aaleemsolutions

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@jeffhandley jeffhandley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I’m not sure InvalidOperationException is the right exception type for this failure. @adamsitnik, do you have thoughts on what callers should receive here?

I’m also concerned about including the MCP server’s raw error text in the exception message. It may contain sensitive details such as file paths or parser diagnostics, and exception messages can flow through logs, telemetry, IngestionResult.Exception, or potentially all the way to an end user. Since MCP is an implementation detail of this reader, could we expose a stable, sanitized conversion error instead?

@jeffhandley
jeffhandley requested a review from adamsitnik August 10, 2026 22:29
Comment on lines +92 to +93
// FIX: Check if the tool execution returned an error (handles bool?)
if (result.IsError == true)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This code comment shouldn't have "FIX: " in it and the "(handles bool?)" is a bit confusing on first glance. The comment is actually superfluous anyway.

Suggested change
// FIX: Check if the tool execution returned an error (handles bool?)
if (result.IsError == true)
if (result.IsError == true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MarkItDownMcpReader ignores tool IsError (returns error text as content)`

3 participants