From dfc3328955c3e1dee184b0710750869e33b7ebc0 Mon Sep 17 00:00:00 2001 From: JonnyTran Date: Sun, 23 Aug 2026 14:48:56 -0700 Subject: [PATCH] fix(server): restore put_document_file's workspace_name parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The obstore refactor renamed the parameter to `workspace` but left both callers passing `workspace_name=`, so every document upload raised TypeError and returned a 500: api/handlers/v1/documents.py:82 POST /api/v1/documents contexts/imports.py:432 bulk import v0.7.1's integration suite caught it, which is why that release was never published to PyPI. The unit test passed the argument positionally, so the mismatch was invisible to the unit suite that gates most PRs — it now calls by keyword, which is what makes this class of break detectable there. Renames the parameter rather than the two call sites, keeping the public signature identical to v0.7.0 so no caller outside this repo has to change. --- extralit-server/src/extralit_server/contexts/files.py | 8 ++++---- extralit-server/tests/unit/contexts/test_files_store.py | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/extralit-server/src/extralit_server/contexts/files.py b/extralit-server/src/extralit_server/contexts/files.py index bc2b87f21..123561f60 100644 --- a/extralit-server/src/extralit_server/contexts/files.py +++ b/extralit-server/src/extralit_server/contexts/files.py @@ -383,7 +383,7 @@ async def delete_document_artifacts(storage: ObjectStorage, workspace: str, docu async def put_document_file( storage: ObjectStorage, - workspace: str, + workspace_name: str, document_id: UUID, file_data: bytes, filename: str, @@ -399,7 +399,7 @@ async def put_document_file( object_path = get_pdf_s3_object_path(document_id) try: - existing_files = await list_objects(storage, workspace, prefix=object_path, recursive=False) + existing_files = await list_objects(storage, workspace_name, prefix=object_path, recursive=False) should_upload = True if existing_files.objects: @@ -412,9 +412,9 @@ async def put_document_file( should_upload = False if should_upload: - await _put(storage, workspace, object_path, file_data, content_type, metadata) + await _put(storage, workspace_name, object_path, file_data, content_type, metadata) - return get_proxy_document_url(workspace, object_path) + return get_proxy_document_url(workspace_name, object_path) return None diff --git a/extralit-server/tests/unit/contexts/test_files_store.py b/extralit-server/tests/unit/contexts/test_files_store.py index 78235e15c..af47a7b9b 100644 --- a/extralit-server/tests/unit/contexts/test_files_store.py +++ b/extralit-server/tests/unit/contexts/test_files_store.py @@ -178,7 +178,13 @@ class TestPutDocumentFile: async def test_the_first_upload_returns_a_proxy_url(self, storage): from uuid import uuid4 - url = await files.put_document_file(storage, WORKSPACE, uuid4(), b"%PDF-1.4", "a.pdf") + url = await files.put_document_file( + storage=storage, + workspace_name=WORKSPACE, + document_id=uuid4(), + file_data=b"%PDF-1.4", + filename="a.pdf", + ) assert url is not None assert url.startswith(f"/api/v1/file/{WORKSPACE}/pdf/")