Skip to content

Commit

Permalink
Remove filenames from BadZipFile error message (#283)
Browse files Browse the repository at this point in the history
In many cases these are tempfiles and just create additional noise.
  • Loading branch information
awalker4 authored Oct 13, 2023
1 parent 1121f12 commit 3929ec5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.53-dev0

* Simplify the error message for BadZipFile errors

## 0.0.52

* Bump unstructured to 0.10.21
Expand Down
2 changes: 1 addition & 1 deletion prepline_general/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
4 changes: 2 additions & 2 deletions prepline_general/api/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion preprocessing-pipeline-family.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name: general
version: 0.0.52
version: 0.0.53
2 changes: 1 addition & 1 deletion test_general/api/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 3929ec5

Please sign in to comment.