Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.39

* **Remove wrap_error logic as exceptions are categorized in unstructured-ingest**

## 0.0.29

* **Support persisting file data changes**
Expand Down
2 changes: 1 addition & 1 deletion unstructured_platform_plugins/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.38" # pragma: no cover
__version__ = "0.0.39" # pragma: no cover
11 changes: 6 additions & 5 deletions unstructured_platform_plugins/etl_uvicorn/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from uvicorn.config import LOG_LEVELS
from uvicorn.importer import import_from_string

from unstructured_platform_plugins.etl_uvicorn.errors import wrap_error
from unstructured_platform_plugins.etl_uvicorn.otel import get_metric_provider, get_trace_provider
from unstructured_platform_plugins.etl_uvicorn.utils import (
get_func,
Expand Down Expand Up @@ -185,15 +184,16 @@ async def _stream_response():
)
except Exception as e:
logger.error(f"Failure streaming response: {e}", exc_info=True)
http_error = wrap_error(e)
yield (
InvokeResponse(
usage=usage,
message_channels=message_channels,
filedata_meta=filedata_meta_model.model_validate(
filedata_meta.model_dump()
),
status_code=http_error.status_code,
status_code=e.status_code
if hasattr(e, "status_code")
else status.HTTP_500_INTERNAL_SERVER_ERROR,
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

The inline conditional logic for status_code extraction is duplicated in two places (lines 194-196 and 233-235). Consider extracting this logic into a helper function to reduce code duplication and improve maintainability.

Suggested change
else status.HTTP_500_INTERNAL_SERVER_ERROR,
status_code=get_status_code_from_exception(e),

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

code duplication is minimum here

status_code_text=f"[{e.__class__.__name__}] {e}",
).model_dump_json()
+ "\n"
Expand Down Expand Up @@ -226,12 +226,13 @@ async def _stream_response():
)
except Exception as invoke_error:
logger.error(f"failed to invoke plugin: {invoke_error}", exc_info=True)
http_error = wrap_error(invoke_error)
return InvokeResponse(
usage=usage,
message_channels=message_channels,
filedata_meta=filedata_meta_model.model_validate(filedata_meta.model_dump()),
status_code=http_error.status_code,
status_code=invoke_error.status_code
if hasattr(invoke_error, "status_code")
else status.HTTP_500_INTERNAL_SERVER_ERROR,
status_code_text=f"[{invoke_error.__class__.__name__}] {invoke_error}",
file_data=request_dict.get("file_data", None),
)
Expand Down
56 changes: 0 additions & 56 deletions unstructured_platform_plugins/etl_uvicorn/errors.py

This file was deleted.