-
Notifications
You must be signed in to change notification settings - Fork 273
Return useful error message for AIs if we fail to deserialize custom datatypes #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds error handling for unsupported complex PostgreSQL data types by catching InvalidCastException during query result processing. When the Npgsql data reader encounters non-standard data types (such as extension or user-defined types) that cannot be converted to strings, the code now throws a CommandValidationException with detailed guidance for the user on how to resolve the issue.
- Added try-catch block around
reader[i]?.ToString()to handleInvalidCastExceptionwhen reading query results - Throws
CommandValidationExceptionwith actionable error message including column name and remediation steps - Added necessary imports:
System.NetandAzure.Mcp.Core.Exceptions
kk-src
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add test for this with the PR.
Hi @kk-src , this simple request had more work than what I have imagined, turns out that the I have refactored the code so we can use mocked services for If you agree with the changes please approve the PR, in any case when you have a chance would like to talk to you about the pre-existing unit tests and what we should do to fix them. |
What does this PR do?
Return useful error message for AIs if we fail to deserialize custom data types, the error message contains instructions for getting the table schema, cast them to out-of-the-box data types and retry the operation.
GitHub issue number?
#279
Pre-merge Checklist
servers/Azure.Mcp.Server/CHANGELOG.mdand/orservers/Fabric.Mcp.Server/CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies)servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationeng/scripts/Process-PackageReadMe.ps1. See Package README/servers/Azure.Mcp.Server/docs/azmcp-commands.mdand/or/docs/fabric-commands.md.\eng\scripts\Update-AzCommandsMetadata.ps1to update tool metadata in azmcp-commands.md (required for CI)ToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test prompts/servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline