Skip to content

Commit

Permalink
Merge pull request #998 from roboflow/fix/handle-WorkflowSyntaxError-…
Browse files Browse the repository at this point in the history
…separately-from-WorkflowDefinitionError

Handle WorkflowSyntaxError separately from WorkflowDefinitionError
  • Loading branch information
grzegorz-roboflow authored Feb 5, 2025
2 parents 7e36cae + 1e8cc15 commit 53c7572
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions inference/core/interfaces/http/http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
WorkflowDefinitionError,
WorkflowError,
WorkflowExecutionEngineVersionError,
WorkflowSyntaxError,
)
from inference.core.workflows.execution_engine.core import (
ExecutionEngine,
Expand Down Expand Up @@ -310,6 +311,15 @@ async def wrapped_route(*args, **kwargs):
},
)
traceback.print_exc()
except WorkflowSyntaxError as error:
content = WorkflowErrorResponse(
message=error.public_message,
error_type=error.__class__.__name__,
context=error.context,
inner_error_type=error.inner_error_type,
inner_error_message=str(error.inner_error),
)
resp = JSONResponse(status_code=400, content=content)
except (
WorkflowDefinitionError,
ExecutionGraphStructureError,
Expand All @@ -322,17 +332,15 @@ async def wrapped_route(*args, **kwargs):
WorkflowExecutionEngineVersionError,
NotSupportedExecutionEngineError,
) as error:
content = WorkflowErrorResponse(
message=error.public_message,
error_type=error.__class__.__name__,
context=error.context,
inner_error_type=error.inner_error_type,
inner_error_message=str(error.inner_error),
blocks_errors=error._blocks_errors,
)
resp = JSONResponse(
status_code=400,
content=content.model_dump(),
content={
"message": error.public_message,
"error_type": error.__class__.__name__,
"context": error.context,
"inner_error_type": error.inner_error_type,
"inner_error_message": str(error.inner_error),
},
)
except (
ProcessesManagerInvalidPayload,
Expand Down

0 comments on commit 53c7572

Please sign in to comment.