fix: discover-tools usa permissao read + erros honestos (nao 503 mascarado)#23
Merged
Merged
Conversation
…request - custom-mcp-servers/discover-tools exigia a action 'discover' que NÃO existe no catálogo (resource_actions_config só tem read/create/update/delete/test) → 403 pra TODOS, inclusive super_admin. discover-tools é uma LEITURA (enumera as tools) → usa 'read'. - exception_handlers (http_exception_handler + base_api_exception_handler) chamavam error_response() SEM o 1º arg obrigatório 'request' → TypeError, que o EvoAuthMiddleware pegava no except Exception e convertia num 503 genérico, mascarando o 403/erro real. Passa request (já no escopo do handler). Provado: discover-tools 503→403→200 end-to-end.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts authorization for the custom MCP server discover-tools endpoint to use an existing read action and fixes exception handlers so HTTP/BaseAPI errors return accurate responses instead of being masked as generic 503s. Sequence diagram for discover_tools authorization and error handlingsequenceDiagram
actor User
participant API as custom_mcp_servers_routes
participant Auth as RequirePermission
participant EH as http_exception_handler
participant ER as error_response
User->>API: POST create_discover_tools
API->>Auth: RequirePermission(ai_custom_mcp_servers, read)
alt permission granted
Auth-->>API: None
API-->>User: 200 DiscoverToolsResponse
else permission denied
Auth-->>API: raise HTTPException(status_code=403)
API-->>EH: HTTPException
EH->>ER: error_response(request, code, message, details)
ER-->>User: 403 JSONResponse
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Now that
error_responserequires arequest, double-check other callers to ensure they’re updated as well, or consider enforcing this via a typed interface to avoid future TypeErrors. - The new inline comments in
create_discover_toolsare in Portuguese; consider standardizing to the project’s primary language (likely English) for consistency and easier maintenance.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Now that `error_response` requires a `request`, double-check other callers to ensure they’re updated as well, or consider enforcing this via a typed interface to avoid future TypeErrors.
- The new inline comments in `create_discover_tools` are in Portuguese; consider standardizing to the project’s primary language (likely English) for consistency and easier maintenance.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dois bugs que travavam criar Servidor MCP Personalizado (500):
Provado end-to-end: 503 -> 403 honesto -> 200.
Summary by Sourcery
Align custom MCP server tool discovery permissions with existing read action and fix error handling to return accurate HTTP errors instead of generic 503 responses.
Bug Fixes: