From d2fca0adbde4c623dc283e422d7852f797166e11 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Wed, 28 Jan 2026 03:24:53 -0600 Subject: [PATCH] fix(workspace): add proper error logging to file download fallback Log exceptions with context (file.id, storagePath) when signed URL generation fails, and wrap fallback streaming in try/except to avoid silently swallowing errors. Co-Authored-By: Claude Opus 4.5 --- .../backend/api/features/workspace/routes.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/autogpt_platform/backend/backend/api/features/workspace/routes.py b/autogpt_platform/backend/backend/api/features/workspace/routes.py index 4d02c1f850..b6d0c84572 100644 --- a/autogpt_platform/backend/backend/api/features/workspace/routes.py +++ b/autogpt_platform/backend/backend/api/features/workspace/routes.py @@ -78,10 +78,24 @@ async def _create_file_download_response(file) -> Response: content = await storage.retrieve(file.storagePath) return _create_streaming_response(content, file) return fastapi.responses.RedirectResponse(url=url, status_code=302) - except Exception: + except Exception as e: + # Log the signed URL failure with context + logger.error( + f"Failed to get signed URL for file {file.id} " + f"(storagePath={file.storagePath}): {e}", + exc_info=True, + ) # Fall back to streaming directly from GCS - content = await storage.retrieve(file.storagePath) - return _create_streaming_response(content, file) + try: + content = await storage.retrieve(file.storagePath) + return _create_streaming_response(content, file) + except Exception as fallback_error: + logger.error( + f"Fallback streaming also failed for file {file.id} " + f"(storagePath={file.storagePath}): {fallback_error}", + exc_info=True, + ) + raise @router.get(