Skip to content

Commit e5c77de

Browse files
Address blocking comment: move bytes validation to VellumJsonEncoder and remove per-chunk overhead
Co-Authored-By: [email protected] <[email protected]>
1 parent 1ec1d71 commit e5c77de

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/vellum/utils/json_encoder.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def default(self, obj: Any) -> Any:
4848
if hasattr(obj, "__vellum_encode__") and callable(getattr(obj, "__vellum_encode__")):
4949
return obj.__vellum_encode__()
5050

51+
if isinstance(obj, (bytes, bytearray)):
52+
raise TypeError(
53+
"bytes are not JSON-serializable; convert to text (e.g., .decode('utf-8')) "
54+
"or base64-encode before returning from a node output"
55+
)
56+
5157
if isinstance(obj, UUID):
5258
return str(obj)
5359

src/vellum/workflows/runner/runner.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -572,16 +572,6 @@ def initiate_node_streaming_output(
572572

573573
with execution_context(parent_context=updated_parent_context, trace_id=execution.trace_id):
574574
for output in node_run_response:
575-
try:
576-
default_serializer(output)
577-
except (TypeError, ValueError) as exc:
578-
raise NodeException(
579-
message=(
580-
f"Node {node.__class__.__name__} produced output: "
581-
f"'{output.name}' that could not be serialized to JSON: {exc}"
582-
),
583-
code=WorkflowErrorCode.INVALID_OUTPUTS,
584-
) from exc
585575
invoked_ports = output > ports
586576
if output.is_initiated:
587577
yield from initiate_node_streaming_output(output)

0 commit comments

Comments
 (0)