Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more precise error when rabbitMQ cannot be reached when storing raw files #3774

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bytes/bytes/api/router.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from base64 import b64decode
from uuid import UUID

import pika.exceptions
import structlog
from cachetools import TTLCache, cached
from fastapi import APIRouter, Depends, HTTPException, Query
Expand Down Expand Up @@ -190,6 +191,11 @@ def create_raw(
raw_data=RawDataMeta(id=raw_id, boefje_meta=raw_data.boefje_meta, mime_types=raw_data.mime_types),
)
event_manager.publish(event)
except pika.exceptions.AMQPError as error:
logger.exception("Error sending 'new raw data' event to RabbitMQ")
raise HTTPException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we want to expose to someone using the API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say, yes? Its an authenticated user, and their request failed.

status_code=codes.INTERNAL_SERVER_ERROR, detail="Error sending 'new raw data' event to RabbitMQ"
) from error
except Exception as error:
logger.exception("Error saving raw data")
raise HTTPException(status_code=codes.INTERNAL_SERVER_ERROR, detail="Could not save raw data") from error
Expand Down
Loading