mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-25 11:10:43 +08:00
fix: guard against non-dict artifacts in output log building
When a component like Chroma (using chromadb internally) stores a threading.Lock object as an artifact value, the code in ResultData.validate_model() and build_output_logs() would crash with TypeError because it tried to use the 'in' operator on a non-dict object. - ResultData.validate_model(): skip artifacts that are not dicts before checking for 'stream_url' and 'type' keys - build_output_logs(): guard STREAM case with isinstance(message, dict) check, and guard ARRAY case against None message Fixes #12591
This commit is contained in:
@ -39,6 +39,9 @@ class ResultData(BaseModel):
|
||||
if message is None:
|
||||
continue
|
||||
|
||||
if not isinstance(message, dict):
|
||||
continue
|
||||
|
||||
if "stream_url" in message and "type" in message:
|
||||
stream_url = StreamURL(location=message["stream_url"])
|
||||
values["outputs"].update({key: OutputValue(message=stream_url, type=message["type"])})
|
||||
|
||||
@ -110,7 +110,7 @@ def build_output_logs(vertex, result) -> dict:
|
||||
type_ = get_type(output_result)
|
||||
|
||||
match type_:
|
||||
case LogType.STREAM if "stream_url" in message:
|
||||
case LogType.STREAM if isinstance(message, dict) and "stream_url" in message:
|
||||
message = StreamURL(location=message["stream_url"])
|
||||
|
||||
case LogType.STREAM:
|
||||
@ -123,9 +123,13 @@ def build_output_logs(vertex, result) -> dict:
|
||||
message = ""
|
||||
|
||||
case LogType.ARRAY:
|
||||
if isinstance(message, DataFrame):
|
||||
if message is None:
|
||||
message = []
|
||||
elif isinstance(message, DataFrame):
|
||||
message = message.to_dict(orient="records")
|
||||
message = [serialize(item) for item in message]
|
||||
message = [serialize(item) for item in message]
|
||||
else:
|
||||
message = [serialize(item) for item in message]
|
||||
name = output.get("name", f"output_{index}")
|
||||
outputs |= {name: OutputValue(message=message, type=type_).model_dump()}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user