Repository: paperless-ngx/paperless-ngx (language: python)

Issue:
[BUG] OAuth JWT size is larger than the database field varchar(3072)
### Description

Attempting to add M365 Outlook account via OAuth but the JWT returned via the callback is larger than the database field.

See logs below (note I've scrambled the JWT so it won't decode but the length is the same 3263 characters long. The greater length is due to the number of additional tenants the UID is linked to. 



### Steps to reproduce

Connect to Microsoft online OAuth service and login 

### Webserver logs

```bash
db-1         | 2024-10-30 03:44:34.722 UTC [26] LOG:  checkpoint complete: wrote 33 buffers (0.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=3.016 s, sync=0.004 s, total=3.029 s; sync files=25, longest=0.002 s, average=0.001 s; distance=140 kB, estimate=140 kB; lsn=0/2925F90, redo lsn=0/2925F58
db-1         | 2024-10-30 03:44:43.603 UTC [88] ERROR:  value too long for type character varying(3072)
db-1         | 2024-10-30 03:44:43.603 UTC [88] STATEMENT:  INSERT INTO "paperless_mail_mailaccount" ("owner_id", "name", "imap_server", "imap_port", "imap_security", "username", "password", "is_token", "character_set", "account_type", "refresh_token", "expiration") VALUES (NULL, 'Outlook OAuth 2024-10-30 03:44:43.348111+00:00', 'outlook.office365.com', 993, 2, '', 'eyJ0eXAiOiJKV1QiLCJubMCIsImtpZCI6IjNQYUs0RWZ5Qk5RdTNDdGpZc2EzWW1oUTVFMCJ9.eyJhdWQiOiJodHRwczovL291dGxvb2sub2ZmaWNlpbmRvd3MubmV0LzFhN2RkOTdkLTgzNTItNGYzOS1iZDE5LWE4Zjc5ZjkwOThkMi8iLCJpYXQiOjE3MzAyNTk1ODMsIm5iZiI6MTczMDI1OTU4MywiZXhwIjoxNzMwMjY1MDMxLCJhY2N0IjowLCJhY3IiOiIxIiwiYWdlR3JvdXAiOiIzIiwiYWlvIjoiQWJRQVMvOFlBQUFBMWwmZGRlOWFhMGIxZiIsImYyZWY5OTJjLTNhZmItNDZiOyRjZvODV0TUg5ZGdBWXRldWJrU1FNQVU5b0lCRUs5cCttQTEyZCtlTXloSHErTVVxZnBObnNMc203Nk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_NjoDsYoBKWkiLnzo_x8dZCU4FGTcBGa-lBeb_HTXIVQgRgj8jC4ZNq5al_S3Ke-z1bj_SRv1G9VMYGs7rIPQ7c4beI-4Szoy0vAFNVt3k-5qMnvf6qlW46VLwgF7le_oCOU0t4d1jL4jVagL6kCjEgnRxftNErwGc6fJsud0qKd5ZOlHHXIud5hTJq-UAOABIw7hwKFGFkuZhBuu-In3dl1Rqs36faoPi6VwllcmtEVTVWCWm6i3ujeEcpr6Iw_kG21ylHDaDLmJvt5oFaNnIfCVDzcjr-jNNl09XEh_LoaAY9X7Hqp5NI9ATctXFpMbPqfOSJcA6GxPZ3UC_P88x4wGIkvhXrEM6E4bcVV9KCfZ2QI7q86kERtDPlDKjKy5iBZvQOSu0A7JXQ2cU8Rhv0M11zfzO22Avpaoog6mYg0Gcd7kpZ9l37pFFsyTWNI2qWQNOCL_ehcI-oVgWJUvc7guqc0VlWr0wmsFym47TDSe9vcLrSBsHwKG_JSrHkWiTU5WXy-uNMKQipKR-yR8U39NYDkEUtTGU_TTVEq-TEStrsYq96UsUOwAXVs3rSBwCrR8gnOrc491F4_HscowBRQmI8UP1BujlbN8XGTWgvqmQk_yxneBe8NYCmEAx-chRGOeUpTtv0WYVv5gEu8DvPUFY6Esayq3wwOzc54wT-aS6Iq7nivKtpSQQ-FqZRX8_1BZiQlV_sbxsVV0kTQnKQGpFhXeLXEXnnf822mfV95_nMhyJqRzkZt2zvHeweonqkgiZkYFkN9w5rabnjoUqUCNw3if_cqSvy1eg6xCHOBex9vtiUgQbe8', '2024-10-30 05:10:30.599636+00:00'::timestamptz) RETURNING "paperless_mail_mailaccount"."id"
webserver-1  | [2024-10-30 03:44:43,606] [ERROR] [django.request] Internal Server Error: /api/oauth/callback/
webserver-1  | Traceback (most recent call last):
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 948, in get_or_create
webserver-1  |     return self.get(**kwargs), False
webserver-1  |            ^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 649, in get
webserver-1  |     raise self.model.DoesNotExist(
webserver-1  | paperless_mail.models.MailAccount.DoesNotExist: MailAccount matching query does not exist.
webserver-1  |
webserver-1  | During handling of the above exception, another exception occurred:
webserver-1  |
webserver-1  | Traceback (most recent call last):
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
webserver-1  |     return self.cursor.execute(sql, params)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
webserver-1  |     raise ex.with_traceback(None)
webserver-1  | psycopg.errors.StringDataRightTruncation: value too long for type character varying(3072)
webserver-1  |
webserver-1  | The above exception was the direct cause of the following exception:
webserver-1  |
webserver-1  | Traceback (most recent call last):
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler
webserver-1  |     raise exc_info[1]
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 42, in inner
webserver-1  |     response = await get_response(request)
webserver-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler
webserver-1  |     raise exc_info[1]
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
webserver-1  |     response = await wrapped_callback(
webserver-1  |                ^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 468, in __call__
webserver-1  |     ret = await asyncio.shield(exec_coro)
webserver-1  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/asgiref/current_thread_executor.py", line 40, in run
webserver-1  | [2024-10-30 03:42:59,856] [ERROR] [django.request] Internal Server Error: /api/oauth/callback/
webserver-1  | Traceback (most recent call last):
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 948, in get_or_create
webserver-1  |     return self.get(**kwargs), False
webserver-1  |            ^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 649, in get
webserver-1  |     raise self.model.DoesNotExist(
webserver-1  | paperless_mail.models.MailAccount.DoesNotExist: MailAccount matching query does not exist.
webserver-1  |
webserver-1  | During handling of the above exception, another exception occurred:
webserver-1  |
webserver-1  | Traceback (most recent call last):
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
webserver-1  |     return self.cursor.execute(sql, params)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
webserver-1  |     raise ex.with_traceback(None)
webserver-1  | psycopg.errors.StringDataRightTruncation: value too long for type character varying(3072)
webserver-1  |
webserver-1  | The above exception was the direct cause of the following exception:
webserver-1  |
webserver-1  | Traceback (most recent call last):
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler
webserver-1  |     raise exc_info[1]
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 42, in inner
webserver-1  |     response = await get_response(request)
webserver-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 468, in __call__
webserver-1  |     ret = await asyncio.shield(exec_coro)
webserver-1  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/asgiref/current_thread_executor.py", line 40, in run
webserver-1  |     result = self.fn(*self.args, **self.kwargs)
webserver-1  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 522, in thread_handler
webserver-1  |     return func(*args, **kwargs)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
webserver-1  |     return view_func(request, *args, **kwargs)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view
webserver-1  |     return self.dispatch(request, *args, **kwargs)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 509, in dispatch
webserver-1  |     response = self.handle_exception(exc)
webserver-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 469, in handle_exception
webserver-1  |     self.raise_uncaught_exception(exc)
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
webserver-1  |     raise exc
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 506, in dispatch
webserver-1  |     response = handler(request, *args, **kwargs)
webserver-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/src/paperless/src/paperless_mail/views.py", line 153, in get
webserver-1  |     account, _ = MailAccount.objects.update_or_create(
webserver-1  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method
webserver-1  |     return getattr(self.get_queryset(), name)(*args, **kwargs)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 986, in update_or_create
webserver-1  |     obj, created = self.select_for_update().get_or_create(
webserver-1  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 955, in get_or_create
webserver-1  |     return self.create(**params), True
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 679, in create
webserver-1  |     obj.save(force_insert=True, using=self.db)
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 891, in save
webserver-1  |     self.save_base(
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 997, in save_base
webserver-1  |     updated = self._save_table(
webserver-1  |               ^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 1160, in _save_table
webserver-1  |     results = self._do_insert(
webserver-1  |               ^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 1201, in _do_insert
webserver-1  |     return manager._insert(
webserver-1  |            ^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method
webserver-1  |     return getattr(self.get_queryset(), name)(*args, **kwargs)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1847, in _insert
webserver-1  |     return query.get_compiler(using=using).execute_sql(returning_fields)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1836, in execute_sql
webserver-1  |     cursor.execute(sql, params)
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 79, in execute
webserver-1  |     return self._execute_with_wrappers(
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
webserver-1  |     return executor(sql, params, many, context)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 100, in _execute
webserver-1  |     with self.db.wrap_database_errors:
webserver-1  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
webserver-1  |     raise dj_exc_value.with_traceback(traceback) from exc_value
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
webserver-1  |     return self.cursor.execute(sql, params)
webserver-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webserver-1  |   File "/usr/local/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
webserver-1  |     raise ex.with_traceback(None)
webserver-1  | django.db.utils.DataError: value too long for type character varying(3072)
```


### Browser logs

_No response_

### Paperless-ngx version

2.13.2

### Host OS

Ubuntu 24.04 / Docker 

### Installation method

Docker - official image

### System status

_No response_

### Browser

_No response_

### Configuration changes

_No response_

### Please confirm the following

- [X] I believe this issue is a bug that affects all users of Paperless-ngx, not something specific to my installation.
- [X] This issue is not about the OCR or archive creation of a specific file(s). Otherwise, please see above regarding OCR tools.
- [X] I have already searched for relevant existing issues and discussions before opening this report.
- [X] I have updated the title field above with a concise description.


Discussion / hints:

Fix patch:
diff --git a/src/paperless_mail/migrations/0028_alter_mailaccount_password_and_more.py b/src/paperless_mail/migrations/0028_alter_mailaccount_password_and_more.py
new file mode 100644
index 00000000000..2a027965154
--- /dev/null
+++ b/src/paperless_mail/migrations/0028_alter_mailaccount_password_and_more.py
@@ -0,0 +1,31 @@
+# Generated by Django 5.1.1 on 2024-10-30 04:31
+
+from django.db import migrations
+from django.db import models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        (
+            "paperless_mail",
+            "0027_mailaccount_expiration_mailaccount_account_type_and_more",
+        ),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="mailaccount",
+            name="password",
+            field=models.TextField(verbose_name="password"),
+        ),
+        migrations.AlterField(
+            model_name="mailaccount",
+            name="refresh_token",
+            field=models.TextField(
+                blank=True,
+                help_text="The refresh token to use for token authentication e.g. with oauth2.",
+                null=True,
+                verbose_name="refresh token",
+            ),
+        ),
+    ]
diff --git a/src/paperless_mail/models.py b/src/paperless_mail/models.py
index 6ba00151dc4..46b9db1ff44 100644
--- a/src/paperless_mail/models.py
+++ b/src/paperless_mail/models.py
@@ -42,7 +42,7 @@ class MailAccountType(models.IntegerChoices):
 
     username = models.CharField(_("username"), max_length=256)
 
-    password = models.CharField(_("password"), max_length=3072)
+    password = models.TextField(_("password"))
 
     is_token = models.BooleanField(_("Is token authentication"), default=False)
 
@@ -62,9 +62,8 @@ class MailAccountType(models.IntegerChoices):
         default=MailAccountType.IMAP,
     )
 
-    refresh_token = models.CharField(
+    refresh_token = models.TextField(
         _("refresh token"),
-        max_length=3072,
         blank=True,
         null=True,
         help_text=_(


Test patch:
diff --git a/src/documents/tests/test_migration_workflows.py b/src/documents/tests/test_migration_workflows.py
index 9a911d2e5f1..69f5ed5fbe9 100644
--- a/src/documents/tests/test_migration_workflows.py
+++ b/src/documents/tests/test_migration_workflows.py
@@ -8,7 +8,7 @@ class TestMigrateWorkflow(TestMigrations):
     dependencies = (
         (
             "paperless_mail",
-            "0027_mailaccount_expiration_mailaccount_account_type_and_more",
+            "0028_alter_mailaccount_password_and_more",
         ),
     )