From 86adc377a09bf67087cc9affb4ce597e30ddfbc7 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 1 May 2025 14:45:37 -0700 Subject: [PATCH] Fix: correctly handle empty user for old notes api format, fix frontend API version (#9846) --- src-ui/src/environments/environment.prod.ts | 2 +- src/documents/serialisers.py | 2 +- src/paperless/settings.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src-ui/src/environments/environment.prod.ts b/src-ui/src/environments/environment.prod.ts index c9a59b2d2..2bc42f4e9 100644 --- a/src-ui/src/environments/environment.prod.ts +++ b/src-ui/src/environments/environment.prod.ts @@ -3,7 +3,7 @@ const base_url = new URL(document.baseURI) export const environment = { production: true, apiBaseUrl: document.baseURI + 'api/', - apiVersion: '7', + apiVersion: '8', // match src/paperless/settings.py appTitle: 'Paperless-ngx', version: '2.15.3', webSocketHost: window.location.host, diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index b6f61103f..e340e8525 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -885,7 +885,7 @@ class NotesSerializer(serializers.ModelSerializer): request.version if request else settings.REST_FRAMEWORK["DEFAULT_VERSION"], ) - if api_version < 8: + if api_version < 8 and "user" in ret: user_id = ret["user"]["id"] ret["user"] = user_id diff --git a/src/paperless/settings.py b/src/paperless/settings.py index a83706571..4906b4713 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -342,7 +342,7 @@ REST_FRAMEWORK = { "rest_framework.authentication.SessionAuthentication", ], "DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.AcceptHeaderVersioning", - "DEFAULT_VERSION": "8", + "DEFAULT_VERSION": "8", # match src-ui/src/environments/environment.prod.ts # Make sure these are ordered and that the most recent version appears # last. See api.md#api-versioning when adding new versions. "ALLOWED_VERSIONS": ["1", "2", "3", "4", "5", "6", "7", "8"],