fix: return 400 instead of 500 for image fetch errors (#9157)
**Problem:** When a user sends a message with an image URL that times out or fails to fetch, the server returns a 500 Internal Server Error with a generic message. This is confusing because the user doesn't know what went wrong. **Root Cause:** `LettaImageFetchError` was not registered in the exception handlers, so it bubbled up as an unhandled exception. **Fix:** Register `LettaImageFetchError` with the 400 Bad Request handler. Now users get a clear error message like: ``` Failed to fetch image from https://...: Timeout after 2 attempts ``` This tells users exactly what went wrong so they can retry with a different image or verify the URL is accessible. 👾 Generated with [Letta Code](https://letta.com) Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -38,6 +38,7 @@ from letta.errors import (
|
||||
HandleNotFoundError,
|
||||
LettaAgentNotFoundError,
|
||||
LettaExpiredError,
|
||||
LettaImageFetchError,
|
||||
LettaInvalidArgumentError,
|
||||
LettaInvalidMCPSchemaError,
|
||||
LettaMCPConnectionError,
|
||||
@@ -477,6 +478,7 @@ def create_application() -> "FastAPI":
|
||||
app.add_exception_handler(LettaToolNameConflictError, _error_handler_400)
|
||||
app.add_exception_handler(AgentFileImportError, _error_handler_400)
|
||||
app.add_exception_handler(EmbeddingConfigRequiredError, _error_handler_400)
|
||||
app.add_exception_handler(LettaImageFetchError, _error_handler_400)
|
||||
app.add_exception_handler(ValueError, _error_handler_400)
|
||||
|
||||
# 404 Not Found errors
|
||||
|
||||
Reference in New Issue
Block a user