From ce642409e87bc1bcce43e9ab1c6d15bb788ee8b3 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 3 Dec 2025 10:52:49 -0800 Subject: [PATCH] Chore: add some output of social login errors (#11527) --- src/paperless/adapter.py | 22 ++++++++++++++++++++++ src/paperless/tests/test_adapter.py | 14 ++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/paperless/adapter.py b/src/paperless/adapter.py index f8517a3aa..a4506275e 100644 --- a/src/paperless/adapter.py +++ b/src/paperless/adapter.py @@ -137,3 +137,25 @@ class CustomSocialAccountAdapter(DefaultSocialAccountAdapter): user.save() handle_social_account_updated(None, request, sociallogin) return user + + def on_authentication_error( + self, + request, + provider, + error=None, + exception=None, + extra_context=None, + ): + """ + Just log errors and pass them along. + """ + logger.warning( + f"Social authentication error for provider `{provider!s}`: {error!s} ({exception!s})", + ) + return super().on_authentication_error( + request, + provider, + error, + exception, + extra_context, + ) diff --git a/src/paperless/tests/test_adapter.py b/src/paperless/tests/test_adapter.py index bbd7ff73e..37b8aaa3b 100644 --- a/src/paperless/tests/test_adapter.py +++ b/src/paperless/tests/test_adapter.py @@ -167,3 +167,17 @@ class TestCustomSocialAccountAdapter(TestCase): self.assertEqual(user.groups.count(), 1) self.assertTrue(user.groups.filter(name="group1").exists()) self.assertFalse(user.groups.filter(name="group2").exists()) + + def test_error_logged_on_authentication_error(self): + adapter = get_social_adapter() + request = HttpRequest() + with self.assertLogs("paperless.auth", level="INFO") as log_cm: + adapter.on_authentication_error( + request, + provider="test-provider", + error="Error", + exception="Test authentication error", + ) + self.assertTrue( + any("Test authentication error" in message for message in log_cm.output), + )