From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 5 Dec 2023 17:08:36 +0000 (-0800) Subject: Fix consumption template empty field checking X-Git-Tag: v2.1.0~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03415456bfcfb1032d174c40753611477f94ea18;p=thirdparty%2Fpaperless-ngx.git Fix consumption template empty field checking --- diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index f01d1fc3ac..c13801c06f 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -1175,11 +1175,23 @@ class ConsumptionTemplateSerializer(serializers.ModelSerializer): attrs["sources"] = {DocumentSource.MailFetch.value} # Empty strings treated as None to avoid unexpected behavior - if ("assign_title") in attrs and len(attrs["assign_title"]) == 0: + if ( + "assign_title" in attrs + and attrs["assign_title"] is not None + and len(attrs["assign_title"]) == 0 + ): attrs["assign_title"] = None - if "filter_filename" in attrs and len(attrs["filter_filename"]) == 0: + if ( + "filter_filename" in attrs + and attrs["filter_filename"] is not None + and len(attrs["filter_filename"]) == 0 + ): attrs["filter_filename"] = None - if "filter_path" in attrs and len(attrs["filter_path"]) == 0: + if ( + "filter_path" in attrs + and attrs["filter_path"] is not None + and len(attrs["filter_path"]) == 0 + ): attrs["filter_path"] = None if (