~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat(library): raise PDF storage cap default to 3 GB to match upload validator (#4198)
LearningCircuit7d2adcd126f3
diff --git a/changelog.d/+pdf-storage-3gb.feature.md b/changelog.d/+pdf-storage-3gb.feature.mdnew file mode 100644index 0000000000..a5f737e6d5--- /dev/null+++ b/changelog.d/+pdf-storage-3gb.feature.md@@ -0,0 +1 @@+Per-PDF library storage cap (`research_library.max_pdf_size_mb`) default raised from 100 MB to 3 GB so it no longer silently truncates large academic PDFs after the recent upload-validator bump. The setting's UI ceiling is also raised from 500 MB to 10 GB, and the `PDFStorageManager` / `download_service` fallback defaults are updated to match. Deployments that want a tighter bound can still lower the setting via the UI.diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.mdindex d8fa6bc989..35e05c9706 100644--- a/docs/CONFIGURATION.md+++ b/docs/CONFIGURATION.md@@ -186,7 +186,7 @@ They are not available in the Web UI because they are needed to start the applic| `report.searches_per_section` | `LDR_REPORT_SEARCHES_PER_SECTION` | `2` | Number of web searches to perform per report section. Higher values increase research depth for each section but also increase search engine queries and processing time. Default is 2. | REPORT || `research_library.auto_index_enabled` | `LDR_RESEARCH_LIBRARY_AUTO_INDEX_ENABLED` | `false` | Automatically index documents for RAG search when they are added to collections (via upload or download). Indexing runs in the background without blocking uploads. Disable to defer indexing and improve upload speed for large batches. | APP || `research_library.confirm_deletions` | `LDR_RESEARCH_LIBRARY_CONFIRM_DELETIONS` | `true` | Show confirmation dialogs before delete operations. Recommended to keep enabled to prevent accidental data loss. | APP |-| `research_library.max_pdf_size_mb` | `LDR_RESEARCH_LIBRARY_MAX_PDF_SIZE_MB` | `100` | Maximum allowed PDF file size in megabytes. PDFs larger than this will not be stored. | APP |+| `research_library.max_pdf_size_mb` | `LDR_RESEARCH_LIBRARY_MAX_PDF_SIZE_MB` | `3072` | Maximum allowed PDF file size in megabytes for the research library. PDFs larger than this will not be stored. Uploads are also gated by the per-file upload cap (LDR_SECURITY_UPLOAD_MAX_FILE_SIZE_MB, default 3072 MB / 3 GB) — raising this value above that cap has no effect because uploads are rejected before they reach storage. | APP || `research_library.pdf_storage_mode` | `RESEARCH_LIBRARY_PDF_STORAGE_MODE` | `database` | Choose how PDFs are stored. Each user has their own encrypted database. Database mode stores PDFs encrypted within it (secure, portable, isolated per-user). Filesystem mode stores unencrypted files on disk (faster for large files). None stores only extracted text (smallest footprint). | APP || `research_library.shared_library` | `RESEARCH_LIBRARY_SHARED_LIBRARY` | `false` | When enabled, all users share the same library directory. Documents from all users will be visible to each other. | APP || `research_library.storage_path` | `RESEARCH_LIBRARY_STORAGE_PATH` | `~/Documents/LocalDeepResearch/Library` | Base path for storing research library documents. Each user will have their own subdirectory unless shared library is enabled. | APP |@@ -569,6 +569,7 @@ They are not available in the Web UI because they are needed to start the applic| `security.rate_limit_upload_user` | `LDR_SECURITY_RATE_LIMIT_UPLOAD_USER` | `60 per minute;1000 per hour` | Per-authenticated-user rate limit for file upload endpoints (e.g., RAG collection uploads). Configured via LDR_SECURITY_RATE_LIMIT_UPLOAD_USER environment variable. Multiple limits separated by semicolons (e.g., '60 per minute;1000 per hour'). Requires server restart. | APP || `security.session_remember_me_days` | `LDR_SECURITY_SESSION_REMEMBER_ME_DAYS` | `30` | Number of days a 'Remember Me' session remains valid before requiring re-login. | APP || `security.session_timeout_hours` | `LDR_SECURITY_SESSION_TIMEOUT_HOURS` | `2` | Session timeout in hours for sessions without 'Remember Me' checked. Only applies to internal session validation (browser sessions expire on close). | APP |+| `web.enable_javascript_rendering` | `LDR_WEB_ENABLE_JAVASCRIPT_RENDERING` | `false` | When enabled, falls back to a headless browser (Crawl4AI/Playwright) for pages that need JavaScript to render. Requires Chromium to be installed - the default Docker production image does NOT include it. To enable: install Chromium in the runtime environment (e.g. 'playwright install --with-deps chromium'), then toggle this setting. Note: in our limited (mostly accidental) benchmark comparisons - between dev instances that happened to have Chromium installed and routine Docker runs that did not - JS rendering did not measurably improve research quality, and most of our regular benchmark runs are on Docker without Chromium anyway. Leave disabled unless you have a specific need to scrape JavaScript-only sites. | APP || `web.host` | `LDR_WEB_HOST` | `0.0.0.0` | The host address to listen on. Configured via LDR_WEB_HOST environment variable. Requires server restart. | APP || `web.port` | `LDR_WEB_PORT` | `5000` | The port to listen on. Configured via LDR_WEB_PORT environment variable. Requires server restart. | APP || `web.use_https` | `LDR_WEB_USE_HTTPS` | `true` | Whether to enable HTTPS for the web interface. Configured via LDR_WEB_USE_HTTPS environment variable. Requires server restart. | APP |diff --git a/docs/env_configuration.md b/docs/env_configuration.mdindex d9c4618c95..2170e0217c 100644--- a/docs/env_configuration.md+++ b/docs/env_configuration.md@@ -187,6 +187,24 @@ Database encryption settings are configured exclusively via environment variableFor the full list of database configuration variables, defaults, constraints, and deprecated aliases, see the **Pre-Database (Env-Only) Settings** section in [CONFIGURATION.md](CONFIGURATION.md#pre-database-env-only-settings).+### Upload Size Limit++The per-file upload cap is read from `LDR_SECURITY_UPLOAD_MAX_FILE_SIZE_MB` at startup. The value is in **megabytes**; the default is **3072 MB (3 GB)**. Values must be positive integers; zero, negative, or non-integer values fall back to the default with a warning.++```bash+# Allow up to 5 GB per file+export LDR_SECURITY_UPLOAD_MAX_FILE_SIZE_MB=5120++# Tighten to 100 MB+export LDR_SECURITY_UPLOAD_MAX_FILE_SIZE_MB=100+```++This cap applies to both the research-upload and RAG-collection upload endpoints. A separate library-side setting (`research_library.max_pdf_size_mb`) controls whether a PDF that passes the upload cap can also be *stored* in the library — both default to 3 GB and should typically be raised or lowered together.++Memory usage stays bounded regardless of the cap: multipart uploads are spooled to disk above a 5 MB threshold (`DiskSpoolingRequest.max_form_memory_size`), so the per-file cap does not directly affect RAM consumption.++Requires a server restart to take effect.+### CORS / WebSocket SecurityThese settings control Cross-Origin Resource Sharing (CORS) for API routes and WebSocket connections. For the full list of security environment variables and their defaults, see [CONFIGURATION.md](CONFIGURATION.md#pre-database-env-only-settings).diff --git a/src/local_deep_research/defaults/research_library/library_settings.json b/src/local_deep_research/defaults/research_library/library_settings.jsonindex e99810a519..a8a879bf9f 100644--- a/src/local_deep_research/defaults/research_library/library_settings.json+++ b/src/local_deep_research/defaults/research_library/library_settings.json@@ -73,16 +73,16 @@},"research_library.max_pdf_size_mb": {"category": "research_library",- "description": "Maximum allowed PDF file size in megabytes. PDFs larger than this will not be stored.",+ "description": "Maximum allowed PDF file size in megabytes for the research library. PDFs larger than this will not be stored. Uploads are also gated by the per-file upload cap (LDR_SECURITY_UPLOAD_MAX_FILE_SIZE_MB, default 3072 MB / 3 GB) — raising this value above that cap has no effect because uploads are rejected before they reach storage.","editable": true,- "max_value": 500,+ "max_value": 10240,"min_value": 1,"name": "Maximum PDF Size (MB)","options": null,"step": 10,"type": "APP","ui_element": "number",- "value": 100,+ "value": 3072,"visible": true},"research_library.upload_pdf_storage": {diff --git a/src/local_deep_research/research_library/services/download_service.py b/src/local_deep_research/research_library/services/download_service.pyindex 4460bd5ca4..176d37acde 100644--- a/src/local_deep_research/research_library/services/download_service.py+++ b/src/local_deep_research/research_library/services/download_service.py@@ -37,7 +37,7 @@ from ...database.models.library import (DocumentStatus,DownloadQueue as LibraryDownloadQueue,)-from .pdf_storage_manager import PDFStorageManager+from .pdf_storage_manager import DEFAULT_MAX_PDF_SIZE_MB, PDFStorageManagerfrom ...database.models.research import ResearchResourcefrom ...database.library_init import get_source_type_id, get_default_library_idfrom ...database.session_context import get_user_db_session, safe_rollback@@ -583,7 +583,8 @@ class DownloadService:)max_pdf_size_mb = int(self.settings.get_setting(- "research_library.max_pdf_size_mb", 100+ "research_library.max_pdf_size_mb",+ DEFAULT_MAX_PDF_SIZE_MB,))logger.info(diff --git a/src/local_deep_research/research_library/services/pdf_storage_manager.py b/src/local_deep_research/research_library/services/pdf_storage_manager.pyindex f6420dce9d..3f653aa57f 100644--- a/src/local_deep_research/research_library/services/pdf_storage_manager.py+++ b/src/local_deep_research/research_library/services/pdf_storage_manager.py@@ -22,11 +22,24 @@ from ...database.models.library import Document, DocumentBlobfrom ...security.path_validator import PathValidator+# Default storage cap for individual PDFs (megabytes). Mirrors the+# upload-validator cap (`FileUploadValidator.MAX_FILE_SIZE`, configurable+# via `LDR_SECURITY_UPLOAD_MAX_FILE_SIZE_MB`) so a file that passes the+# upload step won't be silently dropped at storage time. The runtime+# value comes from the `research_library.max_pdf_size_mb` setting; this+# constant is the shared fallback used by every code-level default so the+# limit doesn't drift across files.+DEFAULT_MAX_PDF_SIZE_MB = 3072 # 3 GB++class PDFStorageManager:"""Unified interface for PDF storage across all modes."""def __init__(- self, library_root: Path, storage_mode: str, max_pdf_size_mb: int = 100+ self,+ library_root: Path,+ storage_mode: str,+ max_pdf_size_mb: int = DEFAULT_MAX_PDF_SIZE_MB,):"""Initialize PDF storage manager.@@ -34,7 +47,10 @@ class PDFStorageManager:Args:library_root: Base directory for filesystem storagestorage_mode: One of 'none', 'filesystem', 'database'- max_pdf_size_mb: Maximum PDF file size in MB (default 100)+ max_pdf_size_mb: Maximum PDF file size in MB. Should not+ exceed `FileUploadValidator.MAX_FILE_SIZE` (the upload+ validator's per-file cap, default 3 GB) — uploads above+ that cap are rejected before they reach this layer."""self.library_root = Path(library_root).resolve()self.storage_mode = storage_modediff --git a/src/local_deep_research/security/file_upload_validator.py b/src/local_deep_research/security/file_upload_validator.pyindex 155f89a5cb..58ce773401 100644--- a/src/local_deep_research/security/file_upload_validator.py+++ b/src/local_deep_research/security/file_upload_validator.py@@ -19,6 +19,12 @@ from ..settings.manager import check_env_setting# Built-in default for the per-file upload cap, in megabytes.# Override via the LDR_SECURITY_UPLOAD_MAX_FILE_SIZE_MB environment variable# (or its server-config alias `security.upload_max_file_size_mb`).+#+# A separate library-side cap (`research_library.max_pdf_size_mb`,+# default 3072) gates whether a PDF can be *stored* after upload. Both+# values default to 3 GB so the two boundaries stay aligned; raising the+# library cap above this value has no effect because uploads above this+# cap are rejected before they reach storage._DEFAULT_MAX_FILE_SIZE_MB = 3072 # 3 GBdiff --git a/tests/research_library/services/test_pdf_storage_manager.py b/tests/research_library/services/test_pdf_storage_manager.pyindex c749027325..0b029ab08d 100644--- a/tests/research_library/services/test_pdf_storage_manager.py+++ b/tests/research_library/services/test_pdf_storage_manager.py@@ -15,11 +15,11 @@ class TestPDFStorageManagerInit:"""Tests for PDFStorageManager initialization."""def test_initializes_with_defaults(self, tmp_path):- """Should initialize with default settings."""+ """Should initialize with default settings (3 GB)."""manager = PDFStorageManager(tmp_path, "database")assert manager.library_root == tmp_path.resolve()assert manager.storage_mode == "database"- assert manager.max_pdf_size_bytes == 100 * 1024 * 1024+ assert manager.max_pdf_size_bytes == 3072 * 1024 * 1024def test_initializes_with_custom_max_size(self, tmp_path):"""Should use custom max PDF size."""diff --git a/tests/research_library/services/test_pdf_storage_manager_coverage.py b/tests/research_library/services/test_pdf_storage_manager_coverage.pyindex 8b4ce0f5d2..4d678efde6 100644--- a/tests/research_library/services/test_pdf_storage_manager_coverage.py+++ b/tests/research_library/services/test_pdf_storage_manager_coverage.py@@ -487,4 +487,4 @@ class TestInitValidation:def test_default_max_size(self, tmp_path):mgr = PDFStorageManager(tmp_path, "none")- assert mgr.max_pdf_size_bytes == 100 * 1024 * 1024+ assert mgr.max_pdf_size_bytes == 3072 * 1024 * 1024diff --git a/tests/settings/golden_master_settings.json b/tests/settings/golden_master_settings.jsonindex 1bf862abab..01e60cd0c8 100644--- a/tests/settings/golden_master_settings.json+++ b/tests/settings/golden_master_settings.json@@ -2058,16 +2058,16 @@},"research_library.max_pdf_size_mb": {"category": "research_library",- "description": "Maximum allowed PDF file size in megabytes. PDFs larger than this will not be stored.",+ "description": "Maximum allowed PDF file size in megabytes for the research library. PDFs larger than this will not be stored. Uploads are also gated by the per-file upload cap (LDR_SECURITY_UPLOAD_MAX_FILE_SIZE_MB, default 3072 MB / 3 GB) — raising this value above that cap has no effect because uploads are rejected before they reach storage.","editable": true,- "max_value": 500,+ "max_value": 10240,"min_value": 1,"name": "Maximum PDF Size (MB)","options": null,"step": 10,"type": "APP","ui_element": "number",- "value": 100,+ "value": 3072,"visible": true},"research_library.pdf_storage_mode": {