Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(docreader): report the file size limit in MB (#4670)

LingYi293d659ddd91
diff --git a/docreader/config.py b/docreader/config.py
index fe28e07d4..9964767c9 100644
--- a/docreader/config.py
+++ b/docreader/config.py
@@ -190,7 +190,7 @@ def dump_config(mask_secrets: bool = True) -> Dict[str, Any]:
cfg = CONFIG
d: Dict[str, Any] = {
"DOCREADER_GRPC_MAX_WORKERS": cfg.grpc_max_workers,
- "DOCREADER_GRPC_MAX_FILE_SIZE_MB": cfg.grpc_max_file_size_mb,
+ "DOCREADER_GRPC_MAX_FILE_SIZE_MB": cfg.grpc_max_file_size_mb // (1024 * 1024),
"DOCREADER_GRPC_PORT": cfg.grpc_port,
"DOCREADER_DOCX_MAX_PAGES": cfg.docx_max_pages,
"DOCREADER_MARKITDOWN_MAX_WORKERS": cfg.markitdown_max_workers,
diff --git a/docreader/tests/test_config.py b/docreader/tests/test_config.py
index 847b07d64..749c4b01c 100644
--- a/docreader/tests/test_config.py
+++ b/docreader/tests/test_config.py
@@ -78,5 +78,35 @@ class DocReaderConfigTest(unittest.TestCase):
self.assertIn(key, config.dump_config())
+class FileSizeConfigTest(unittest.TestCase):
+ def _load_file_size(self, env, expected_mb):
+ with patch.dict(os.environ, env, clear=True):
+ cfg = config.load_config()
+ # The gRPC options still consume the converted byte count.
+ self.assertEqual(cfg.grpc_max_file_size_mb, expected_mb * 1024 * 1024)
+ return cfg
+
+ def test_dump_reports_default_file_size_in_mb(self):
+ cfg = self._load_file_size({}, 50)
+ with patch.object(config, "CONFIG", cfg):
+ self.assertEqual(config.dump_config()["DOCREADER_GRPC_MAX_FILE_SIZE_MB"], 50)
+
+ def test_dump_reports_namespaced_file_size_in_mb(self):
+ cfg = self._load_file_size({"DOCREADER_GRPC_MAX_FILE_SIZE_MB": "7"}, 7)
+ with patch.object(config, "CONFIG", cfg):
+ self.assertEqual(config.dump_config()["DOCREADER_GRPC_MAX_FILE_SIZE_MB"], 7)
+
+ def test_dump_reports_legacy_file_size_in_mb(self):
+ cfg = self._load_file_size({"MAX_FILE_SIZE_MB": "3"}, 3)
+ with patch.object(config, "CONFIG", cfg):
+ self.assertEqual(config.dump_config()["DOCREADER_GRPC_MAX_FILE_SIZE_MB"], 3)
+
+ def test_startup_log_reports_file_size_in_mb(self):
+ cfg = self._load_file_size({"DOCREADER_GRPC_MAX_FILE_SIZE_MB": "7"}, 7)
+ with patch.object(config, "CONFIG", cfg), self.assertLogs(config.logger, level="INFO") as logs:
+ config.print_config()
+ self.assertIn("INFO:docreader.config:DOCREADER_GRPC_MAX_FILE_SIZE_MB=7", logs.output)
+
+
if __name__ == "__main__":
unittest.main()