Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion unstructured_platform_plugins/etl_uvicorn/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ async def _stream_response():
usage=usage,
message_channels=message_channels,
filedata_meta=filedata_meta_model.model_validate(filedata_meta.model_dump()),
status_code=wrap_error(exc).status_code,
status_code=exc.status_code,
status_code_text=f"[{exc.__class__.__name__}] {exc}",
file_data=request_dict.get("file_data", None),
)
Expand Down
15 changes: 3 additions & 12 deletions unstructured_platform_plugins/etl_uvicorn/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class UserAuthError(UserError):
status_code: int = 403


class UnprocessableEntityError(UserError):
status_code: int = 422


class RateLimitError(UserError):
status_code: int = 429

Expand All @@ -45,15 +41,10 @@ class CatchAllError(BaseError):


def wrap_error(e: Exception) -> HTTPException:
if isinstance(e, ingest_errors.UserAuthError):
if isinstance(e, HTTPException):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw this is where its called for HTTPException
https://github.com/Unstructured-IO/unstructured-platform-plugins/blob/main/unstructured_platform_plugins/etl_uvicorn/api_generator.py#L219
do you think we can also move status_code=wrap_error(exc).status_code, -> status_code=exc.status_code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh we don't need a case for HTTPException if we don't call this func for it...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i created a dup pr #55
for my ticket 😬

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think we need to call the wrap in that case.
I think I'd leave the case for HTTPException though, it makes sense that HTTPException maps onto itself and there's no good way to indicate you shouldn't feed HTTPExceptions into it.

Copy link
Contributor

@yuming-long yuming-long Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm no i don't get it tho
if you call wrap_error(e = HTTPException) you would get a CatchAllError(e) which will convert you status code to 512
which is the case for my ticket we see a lot of 512 with emppty detail

return e
elif isinstance(e, ingest_errors.UserAuthError):
return UserAuthError(e)
elif isinstance(e, HTTPException):
if e.status_code == 400:
return UserError(e)
if e.status_code == 422:
return UnprocessableEntityError(e)
if e.status_code == 504:
return GatewayTimeoutError(e)
elif isinstance(e, ingest_errors.RateLimitError):
return RateLimitError(e)
elif isinstance(e, ingest_errors.QuotaError):
Expand Down