Validate all block parameters are defined in workflow (#4464)
This commit is contained in:
committed by
GitHub
parent
5bfa0b0961
commit
5e23c580e7
@@ -119,7 +119,11 @@ class InvalidFileType(BaseWorkflowHTTPException):
|
||||
)
|
||||
|
||||
|
||||
class WorkflowParameterMissingRequiredValue(BaseWorkflowHTTPException):
|
||||
class WorkflowDefinitionValidationException(BaseWorkflowHTTPException):
|
||||
"""Base exception for workflow definition validation errors."""
|
||||
|
||||
|
||||
class WorkflowParameterMissingRequiredValue(WorkflowDefinitionValidationException):
|
||||
def __init__(self, workflow_parameter_type: str, workflow_parameter_key: str, required_value: str) -> None:
|
||||
super().__init__(
|
||||
f"Missing required value for workflow parameter. Workflow parameter type: {workflow_parameter_type}. workflow_parameter_key: {workflow_parameter_key}. Required value: {required_value}",
|
||||
@@ -127,6 +131,25 @@ class WorkflowParameterMissingRequiredValue(BaseWorkflowHTTPException):
|
||||
)
|
||||
|
||||
|
||||
class WorkflowDefinitionHasUndefinedParameters(WorkflowDefinitionValidationException):
|
||||
def __init__(self, undefined_parameters: dict[str, list[str]]) -> None:
|
||||
# Format: {"block_label": ["param1", "param2"]}
|
||||
error_details = []
|
||||
for block_label, params in undefined_parameters.items():
|
||||
params_str = ", ".join(f"'{p}'" for p in params)
|
||||
error_details.append(f" - Block '{block_label}' references undefined parameter(s): {params_str}")
|
||||
|
||||
error_message = (
|
||||
f"Workflow definition has blocks that reference undefined parameters:\n"
|
||||
f"{chr(10).join(error_details)}\n\n"
|
||||
f"Make sure to define all parameters in the workflow parameters list before using them in blocks."
|
||||
)
|
||||
super().__init__(
|
||||
error_message,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
)
|
||||
|
||||
|
||||
class InvalidWaitBlockTime(SkyvernException):
|
||||
def __init__(self, max_sec: int) -> None:
|
||||
super().__init__(f"Invalid wait time for wait block, it should be a number between 0 and {max_sec}.")
|
||||
|
||||
Reference in New Issue
Block a user