Skip to content

feature: improve error handling#3

Merged
tyrchen merged 3 commits intomasterfrom
feature/improve-with-codebank
Apr 27, 2025
Merged

feature: improve error handling#3
tyrchen merged 3 commits intomasterfrom
feature/improve-with-codebank

Conversation

@tyrchen
Copy link
Owner

@tyrchen tyrchen commented Apr 27, 2025

No description provided.

@tyrchen tyrchen requested a review from Copilot April 27, 2025 22:11
Copy link

Copilot AI left a 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 focuses on improving error handling across the PostgreSQL MCP codebase. Key changes include adding detailed error variants with PgMcpError in src/pg.rs, updating error mappings in src/mcp.rs to use a dedicated helper (map_pg_error), and adding additional test scenarios for error cases in tests/mcp_test.rs.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/mcp_test.rs Added error scenario tests to verify improved error messaging and SQL validation failures
src/pg.rs Introduced explicit PgMcpError variants and refined SQL validation logic
src/mcp.rs Refactored error mapping to use a dedicated helper function for consistent error conversion
src/main.rs Simplified SSE server startup using serve_with_config
Cargo.toml & documentation Updated dependency versions and adjusted documentation to reflect improved error handling
Comments suppressed due to low confidence (2)

tests/mcp_test.rs:389

  • Using a hard-coded error code substring ('-32603') in your assertions might be brittle if error messages change in the future. Consider checking against structured error variants or error types.
err.to_string().contains("Mcp error: -32603: Connection not found") // Match actual stdio transport error

src/pg.rs:49

  • [nitpick] In the conversion from sqlx::Error to PgMcpError, consider capturing more specific context (e.g. the operation context) instead of defaulting to 'unknown'. This can improve debugging clarity when database errors occur.
if let Some(db_err) = e.as_database_error() {

@tyrchen tyrchen merged commit 48e0e19 into master Apr 27, 2025
1 check passed
@tyrchen tyrchen deleted the feature/improve-with-codebank branch April 27, 2025 22:28
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.

2 participants