From 3929ec5631a77513fcf5587a213ee25931ac7c41 Mon Sep 17 00:00:00 2001 From: Austin Walker Date: Fri, 13 Oct 2023 09:54:45 -0400 Subject: [PATCH] Remove filenames from BadZipFile error message (#283) In many cases these are tempfiles and just create additional noise. --- CHANGELOG.md | 4 ++++ prepline_general/api/app.py | 2 +- prepline_general/api/general.py | 4 ++-- preprocessing-pipeline-family.yaml | 2 +- test_general/api/test_app.py | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9167eaa5..9163b41a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.53-dev0 + +* Simplify the error message for BadZipFile errors + ## 0.0.52 * Bump unstructured to 0.10.21 diff --git a/prepline_general/api/app.py b/prepline_general/api/app.py index 86376fd4..8a3e5cc4 100644 --- a/prepline_general/api/app.py +++ b/prepline_general/api/app.py @@ -11,7 +11,7 @@ app = FastAPI( title="Unstructured Pipeline API", description="""""", - version="0.0.52", + version="0.0.53", docs_url="/general/docs", openapi_url="/general/openapi.json", ) diff --git a/prepline_general/api/general.py b/prepline_general/api/general.py index 3245648c..2b374291 100644 --- a/prepline_general/api/general.py +++ b/prepline_general/api/general.py @@ -467,7 +467,7 @@ def pipeline_api( if "File is not a zip file" in e.args[0]: raise HTTPException( status_code=400, - detail=f"{filename} is not a valid '{file_content_type}' content type", + detail="File is not a valid docx", ) # Clean up returned elements @@ -603,7 +603,7 @@ def return_content_type(filename): @router.post("/general/v0/general") -@router.post("/general/v0.0.52/general") +@router.post("/general/v0.0.53/general") def pipeline_1( request: Request, gz_uncompressed_content_type: Optional[str] = Form(default=None), diff --git a/preprocessing-pipeline-family.yaml b/preprocessing-pipeline-family.yaml index a8cca335..41acd116 100644 --- a/preprocessing-pipeline-family.yaml +++ b/preprocessing-pipeline-family.yaml @@ -1,2 +1,2 @@ name: general -version: 0.0.52 +version: 0.0.53 diff --git a/test_general/api/test_app.py b/test_general/api/test_app.py index 343410be..bd024cb8 100644 --- a/test_general/api/test_app.py +++ b/test_general/api/test_app.py @@ -759,7 +759,7 @@ def test_general_api_returns_400_bad_docx(): ) ], ) - assert "txt is not a valid" in response.json().get("detail") + assert response.json().get("detail") == "File is not a valid docx" assert response.status_code == 400