Skip to content

Add error handling for A2A conversation messages endpoint#183

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1776014396-a2a-conversation-messages-error-handling
Open

Add error handling for A2A conversation messages endpoint#183
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1776014396-a2a-conversation-messages-error-handling

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Adds explicit error handling to the GET /public/apps/<app_id>/a2a/conversations/<conversation_id>/messages route.

Before: An invalid conversation_id (non-UUID string) caused an unhandled ValueError in the service layer, resulting in a generic 500 error. An invalid app_id raised NotFoundException which 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:

  • Service layer (public_agent_a2a_service.py): Wraps UUID(conversation_id) in a try/except to convert ValueError/AttributeError into a ValidateErrorException with a descriptive message.
  • Handler layer (public_app_handler.py): Catches NotFoundException → 404, ValidateErrorException → 400, and generic Exception → 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

  • Verify the existing test test_public_app_a2a_conversation_messages_should_delegate_to_service still passes in CI — local tests could not be run due to missing PostgreSQL/Redis infrastructure.
  • Decide if sibling A2A endpoints (get_public_app_a2a_card, send_public_app_a2a_message, get_latest_public_app_a2a_conversation) should get the same error handling — currently they let NotFoundException bubble to the global handler which returns HTTP 200 with a business error code, creating an inconsistency.
  • Review whether the bare except Exception catch-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

  • The happy path (valid parameters, successful query) is unchanged and still returns success_json(messages).

Link to Devin session: https://app.devin.ai/sessions/c588027acf0a490c8b3467ef8f8fe02b
Requested by: @Haohao-end

- 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>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant