Add error handling for A2A conversation messages endpoint#183
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
Add error handling for A2A conversation messages endpoint#183devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
- Handle invalid app_id (NotFoundException) with 404 response - Handle invalid conversation_id UUID format (ValidateErrorException) with 400 response - Catch unexpected exceptions with 500 response - Validate conversation_id UUID in service layer before DB query Co-Authored-By: Haohao <2227625024@qq.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Adds explicit error handling to the
GET /public/apps/<app_id>/a2a/conversations/<conversation_id>/messagesroute.Before: An invalid
conversation_id(non-UUID string) caused an unhandledValueErrorin the service layer, resulting in a generic 500 error. An invalidapp_idraisedNotFoundExceptionwhich was caught by the global error handler but returned HTTP 200 with a business error code — inconsistent with the A2A pattern of returning proper HTTP status codes (e.g. 503 for service unavailable).Changes:
public_agent_a2a_service.py): WrapsUUID(conversation_id)in a try/except to convertValueError/AttributeErrorinto aValidateErrorExceptionwith a descriptive message.public_app_handler.py): CatchesNotFoundException→ 404,ValidateErrorException→ 400, and genericException→ 500, returning JSON error responses consistent with the existing A2A pattern (e.g. the 503 already returned when the service is unavailable).Review & Testing Checklist for Human
test_public_app_a2a_conversation_messages_should_delegate_to_servicestill passes in CI — local tests could not be run due to missing PostgreSQL/Redis infrastructure.get_public_app_a2a_card,send_public_app_a2a_message,get_latest_public_app_a2a_conversation) should get the same error handling — currently they letNotFoundExceptionbubble to the global handler which returns HTTP 200 with a business error code, creating an inconsistency.except Exceptioncatch-all in the handler is desired — it prevents unexpected errors from reaching the global handler. This is consistent with returning A2A-style JSON errors, but could mask programming bugs during development.Suggested manual test plan: call the endpoint with (1) a valid app_id + valid conversation_id, (2) a non-UUID app_id, (3) a valid app_id + non-UUID conversation_id, (4) a valid UUID that doesn't correspond to any app, and verify you get 200/404/400/404 respectively.
Notes
success_json(messages).Link to Devin session: https://app.devin.ai/sessions/c588027acf0a490c8b3467ef8f8fe02b
Requested by: @Haohao-end