A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fixhancement: better handle empty fields from AI suggestions (#13454)
shamoon919ffdd79459
diff --git a/src/paperless_ai/base_model.py b/src/paperless_ai/base_model.pyindex 61f93b467..3d3820dfc 100644--- a/src/paperless_ai/base_model.py+++ b/src/paperless_ai/base_model.py@@ -1,12 +1,13 @@from pydantic import BaseModel+from pydantic import Fieldclass DocumentClassifierSchema(BaseModel):"""Schema for document classification suggestions."""title: str- tags: list[str]- correspondents: list[str]- document_types: list[str]- storage_paths: list[str]- dates: list[str]+ tags: list[str] = Field(default_factory=list)+ correspondents: list[str] = Field(default_factory=list)+ document_types: list[str] = Field(default_factory=list)+ storage_paths: list[str] = Field(default_factory=list)+ dates: list[str] = Field(default_factory=list)diff --git a/src/paperless_ai/tests/test_base_model.py b/src/paperless_ai/tests/test_base_model.pynew file mode 100644index 000000000..c598f1400--- /dev/null+++ b/src/paperless_ai/tests/test_base_model.py@@ -0,0 +1,35 @@+import pytest+from pydantic import ValidationError++from paperless_ai.base_model import DocumentClassifierSchema+++ "omitted_field",+ [+ "tags",+ "correspondents",+ "document_types",+ "storage_paths",+ "dates",+ ],+)+def test_document_classifier_schema_defaults_omitted_list_field(omitted_field):+ data = {+ "title": "Test Title",+ "tags": ["test"],+ "correspondents": ["Test Correspondent"],+ "document_types": ["Test Document Type"],+ "storage_paths": ["Test Storage Path"],+ "dates": ["2026-07-31"],+ }+ del data[omitted_field]++ result = DocumentClassifierSchema(**data)++ assert getattr(result, omitted_field) == []+++def test_document_classifier_schema_requires_title():+ with pytest.raises(ValidationError, match="title"):+ DocumentClassifierSchema()