From 861010ae864276b4b38c4a47164f5270c01da14e Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Wed, 28 May 2025 14:59:24 +0300 Subject: [PATCH] Features: 1) Add detailed error traceback in activation error response; Fixes: 1) Log complete error traceback for debugging activation failures; Extra: 1) Minor code adjustments and variable addition for error handling; --- vibes_auth/viewsets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vibes_auth/viewsets.py b/vibes_auth/viewsets.py index bfae34a7..d61f47ee 100644 --- a/vibes_auth/viewsets.py +++ b/vibes_auth/viewsets.py @@ -1,4 +1,5 @@ import logging +import traceback from contextlib import suppress from secrets import compare_digest @@ -99,6 +100,7 @@ class UserViewSet( @action(detail=False, methods=["post"]) @method_decorator(ratelimit(key="ip", rate="2/h" if not DEBUG else "888/h")) def activate(self, request): + detail = "" try: uuid = urlsafe_base64_decode(request.data.get("uidb64")).decode() user = User.objects.get(pk=uuid) @@ -117,10 +119,10 @@ class UserViewSet( user.save() except (TypeError, ValueError, OverflowError, User.DoesNotExist) as e: user = None - logger.error(str(e)) + detail = str(traceback.format_exc()) if user is None: return Response( - {"error": _("activation link is invalid!")}, + {"error": _("activation link is invalid!"), "detail": detail}, status=status.HTTP_400_BAD_REQUEST, ) else: