fix(document_extractor): handle empty variable values properly

- Added check for variable.value existence before type validation.
- Prevents erroneous type checks on empty variables, improving robustness.
This commit is contained in:
-LAN- 2024-09-30 13:09:21 +08:00
parent 3ff88f4f3c
commit 94b946c715

View File

@ -41,7 +41,7 @@ class DocumentExtractorNode(BaseNode):
if variable is None:
error_message = f"File variable not found for selector: {variable_selector}"
return NodeRunResult(status=WorkflowNodeExecutionStatus.FAILED, error=error_message)
if not isinstance(variable, ArrayFileSegment | FileSegment):
if variable.value and not isinstance(variable, ArrayFileSegment | FileSegment):
error_message = f"Variable {variable_selector} is not an ArrayFileSegment"
return NodeRunResult(status=WorkflowNodeExecutionStatus.FAILED, error=error_message)