Skip to content

Commit 6bb5f16

Browse files
authored
Return InvokeResponse when handling exception (#52)
Reraising the exception instead of returning InvokeResponse here will cause the plugin-controller to raise a pydantic validation error for the plugin response and as a result, the plugin error info will not be shown to the user.
1 parent 1415299 commit 6bb5f16

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.31" # pragma: no cover
1+
__version__ = "0.0.32" # pragma: no cover

unstructured_platform_plugins/etl_uvicorn/api_generator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,14 @@ async def _stream_response():
212212
logger.error(
213213
f"HTTPException: {exc.detail} (status_code={exc.status_code})", exc_info=True
214214
)
215-
raise
215+
return InvokeResponse(
216+
usage=usage,
217+
message_channels=message_channels,
218+
filedata_meta=filedata_meta_model.model_validate(filedata_meta.model_dump()),
219+
status_code=wrap_error(exc).status_code,
220+
status_code_text=f"[{exc.__class__.__name__}] {exc}",
221+
file_data=request_dict.get("file_data", None),
222+
)
216223
except UnrecoverableException as ex:
217224
logger.info("Unrecoverable error occurred during plugin invocation")
218225
return InvokeResponse(

0 commit comments

Comments
 (0)