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:
octo-patch
2026-04-11 12:50:31 +08:00
parent 1e61ac4ebe
commit 4e0b4e8191
2 changed files with 10 additions and 3 deletions

View File

@ -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"])})

View File

@ -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()}