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

fix: improve logging for message API #3846

Merged
merged 1 commit into from
Oct 5, 2024
Merged
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
11 changes: 7 additions & 4 deletions backend/mlarchive/archive/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jsonschema
import re
import os
import sys
import tempfile

from django.conf import settings
Expand Down Expand Up @@ -238,15 +239,17 @@ def post(self, request, **kwargs):
logger.error(msg)
return self._err(400, msg)
except Exception:
msg = 'Invalid request format'
logger.error(msg)
exc_type, exc_value, exc_traceback = sys.exc_info()
logger.error(f"Exception type: {exc_type}, Exception message: {exc_value}", exc_info=True)
msg = f'Error processing request. ({exc_value})'
return self._err(400, msg)

try:
message = base64.b64decode(payload["message"], validate=True)
except binascii.Error:
msg = 'Invalid message: bad base64 encoding'
logger.error(msg)
exc_type, exc_value, exc_traceback = sys.exc_info()
logger.error(f"Exception type: {exc_type}, Exception message: {exc_value}", exc_info=True)
msg = f'Invalid message: bad base64 encoding ({exc_value})'
return self._err(400, msg)

list_name = payload["list_name"]
Expand Down