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 5 commits into
base: main
Choose a base branch
from

Conversation

underdarknl
Copy link
Contributor

Changes

Specifically catches the rabbitMQ errors which might occur if (even after the retries) it still cannot be reached.
The original 500 does not show the stacktrace in de logs, and as such there is no easy way for the user to know rabbitMQ might be at fault.

Issue link

bytes-1                | $IP:$PORT - "POST /bytes/raw?boefje_meta_id=$SOME_UUID HTTP/1.1" 500
bytes-1                | fastapi.exceptions.HTTPException: 500: Could not save raw data

Closes ...

Demo

Please add some proof in the form of screenshots or screen recordings to show (off) new functionality, if there are interesting new features for end-users.

QA notes

Please add some information for QA on how to test the newly created code.


Code Checklist

  • All the commits in this PR are properly PGP-signed and verified.
  • This PR only contains functionality relevant to the issue.
  • I have written unit tests for the changes or fixes I made.
  • I have checked the documentation and made changes where necessary.
  • I have performed a self-review of my code and refactored it to the best of my abilities.
  • Tickets have been created for newly discovered issues.
  • For any non-trivial functionality, I have added integration and/or end-to-end tests.
  • I have informed others of any required .env changes files if required and changed the .env-dist accordingly.
  • I have included comments in the code to elaborate on what is not self-evident from the code itself, including references to issues and discussions online, or implicit behavior of an interface.

Checklist for code reviewers:

Copy-paste the checklist from the docs/source/templates folder into your comment.


Checklist for QA:

Copy-paste the checklist from the docs/source/templates folder into your comment.

@underdarknl underdarknl requested a review from a team as a code owner October 31, 2024 10:50
Copy link

bytes/bytes/api/router.py Show resolved Hide resolved
@@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this works, because Byte's RabbitMQEventManager.publish already handles the AMQPError exceptions and doesn't reraise them. That could explain the missing stack traces in the logs. However, while the RabbitMQEventManager.publish handles these errors, it could potentially still produce an AMQPError due to subsequent API calls via .e.g basic_publish or queue_declare within the exception handler. But in that case you would still see the warning "Reconnected to RabbitMQ because connection was closed" in the logs before the exception.

But imo the API router shouldn't be dealing with AMQP related stuff. As part of the separation of concerns principle, it's the EventManager that needs to be dealing with this technology details

@ammar92 ammar92 added the 😸 Review/QA feedback Review/QA feedback provided label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😸 Review/QA feedback Review/QA feedback provided
Projects
Status: Review
Development

Successfully merging this pull request may close these issues.

3 participants