remotion-dev/remotion · error · RemotionInvalidArgumentException
Failed to serialize render parameters to JSON: {e}
Error message
Failed to serialize render parameters to JSON: {e} What it means
Thrown by construct_render_request when json.dumps of the full serialized render payload (render_params.serialize_params()) raises TypeError or OverflowError, even after the custom serializer that handles enums, dataclasses, __dict__ and iterables. This means the payload still contained something the custom serializer could not represent (e.g. circular references, very deeply nested integers, or a type the custom serializer falls through on like a custom __dict__ containing non-serializable values).
Source
Thrown at packages/lambda-python/remotion_lambda/remotionclient.py:565
render_params.serve_url = self.serve_url
try:
# Assuming RenderMediaParams and RenderStillParams both have an input_props attribute
# and a private_serialized_input_props attribute (even if Optional)
render_params.private_serialized_input_props = self._serialize_input_props(
input_props=render_params.input_props, render_type=render_type
)
except (RemotionInvalidArgumentException, ClientError) as e:
raise RemotionInvalidArgumentException(
f"Failed to serialize input properties for rendering: {e}"
) from e
# Ensure serialize_params method in models.py is typed to return Dict[str, Any]
payload: Dict[str, Any] = render_params.serialize_params()
try:
return json.dumps(payload, default=self._custom_serializer)
except (TypeError, OverflowError) as e:
raise RemotionInvalidArgumentException(
f"Failed to serialize render parameters to JSON: {e}"
) from e
def construct_render_progress_request(
self,
render_id: str,
bucket_name: str,
log_level: str = "info", # Added type hint
s3_output_provider: Optional[CustomCredentials] = None,
) -> str:
"""
Construct a render progress request in JSON format.
Args:
render_id (str): ID of the render.
bucket_name (str): Name of the bucket.
log_level (str): Log level ("error", "warning", "info", "verbose").
s3_output_provider (Optional[CustomCredentials]): Custom S3 credentials.View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Read the wrapped TypeError/OverflowError message to identify the offending value or recursion depth.
- Ensure every field set on RenderMediaParams/RenderStillParams reduces to JSON primitives or already-serialized dicts before calling render_media_on_lambda/render_still_on_lambda.
- If using custom classes, convert them with to_dict() or dataclasses.asdict() yourself before assigning.
- For OverflowError on large numbers, cap or stringify the value.
Example fix
// before render_params.webhook = MyCustomWebhook() # __dict__ holds a file handle // after render_params.webhook = Webhook(url='https://example.com/hook', secret='...')
Defensive patterns
Strategy: try-catch
Validate before calling
import json
def payload_serializes(params_dict):
try:
json.dumps(params_dict, default=str)
return True
except (TypeError, OverflowError):
return False
if not payload_serializes(render_params.serialize_params()):
raise ValueError('render params contain non-serializable fields') Type guard
from enum import Enum
def serializable_value(v):
if isinstance(v, Enum): return True
if hasattr(v, '__dataclass_fields__'): return True
return v is None or isinstance(v, (str, int, float, bool, list, dict)) Try / catch
from remotion_lambda.exceptions import RemotionInvalidArgumentException
try:
json_str = client.construct_render_request(render_params, render_type='video-or-audio')
except RemotionInvalidArgumentException as e:
logger.exception('Render request serialization failed; payload was: %r', render_params.serialize_params())
raise Prevention
- Avoid assigning custom classes to optional render_params fields; prefer dicts.
- Use dataclasses with primitive fields for webhook/credential structures.
- Test serialization in isolation before submitting the render.
- Never mutate render_params after a successful serialization to inject non-serializable state.
When it happens
Trigger: A render_params field whose value has a __dict__ that recursively references non-serializable objects; a numeric value so large that json.dumps raises OverflowError; a custom object that is not an Enum, dataclass, or iterable, and whose __dict__ still contains unsupported types.
Common situations: Attaching custom nested objects to optional params (e.g. webhook config with arbitrary objects); passing very large integers from compute-heavy props; mutating render_params after construction to inject non-serializable state.
Related errors
- Error serializing InputProps. Check for circular references
- Failed to serialize progress parameters to JSON: {e}
- Failed to parse Lambda response stream: {e}
- Failed to decode final Lambda response: {e}. Raw response: {
- Object of type {obj.__class__.__name__} is not JSON serializ
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/a7b16256862e9a4e.
Report an issue: GitHub.