remotion-dev/remotion · error · RemotionInvalidArgumentException

Error serializing InputProps. Check for circular references

Error message

Error serializing InputProps. Check for circular references or invalid data types in the input properties.

What it means

Raised during input-props staging when json.dumps (or the custom serializer) raises TypeError or OverflowError - typical causes are circular references, deeply nested structures, or non-serializable objects that the custom serializer cannot handle. Distinguished from S3 ClientError which is re-raised separately.

Source

Thrown at packages/lambda-python/remotion_lambda/remotionclient.py:428

            if self._needs_upload(payload_size, render_type):
                hash_value = self._generate_hash(payload)
                bucket_name = self._get_or_create_bucket()
                key = self._input_props_key(hash_value)

                self._upload_to_s3(bucket_name, key, payload)

                return {
                    'type': 'bucket-url',
                    'hash': hash_value,
                    'bucketName': bucket_name,
                }
            return {
                'type': 'payload',
                'payload': payload if payload not in ('', 'null') else json.dumps({}),
            }
        except (TypeError, OverflowError) as error:
            raise RemotionInvalidArgumentException(
                'Error serializing InputProps. Check for circular '
                + 'references or invalid data types in the input properties.'
            ) from error
        except ClientError as e:
            raise e

    def _create_lambda_client(self) -> Any: # Returns a Lambda client type
        """Creates and returns a boto3 Lambda client."""
        return self._create_boto_client('lambda')

    def _find_json_objects(self, input_string: str) -> List[str]: # Added type hints
        """Finds and returns a list of complete JSON object strings."""
        objects: List[str] = []
        depth = 0
        start_index = 0

        for i, char in enumerate(input_string):
            if char == '{':

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Pre-serialize inputProps with json.dumps(..., default=str) locally to surface the offending value.
  2. Convert non-serializable types (datetime->isoformat, Decimal->float, set->list) before rendering.
  3. Break circular references before passing data; use plain dicts/lists of primitives.
  4. If using custom objects, implement a conversion to plain dict/list/scalar before calling render.

Example fix

// before
input_props = {'item': some_sqlalchemy_model, 'parent': container}
input_props['parent']['child'] = input_props  # circular
client.render_media(comp, input_props=input_props)

# after
input_props = {
    'item': {
        'id': some_sqlalchemy_model.id,
        'name': some_sqlalchemy_model.name,
    }
}
client.render_media(comp, input_props=input_props)
Defensive patterns

Strategy: type-guard

Validate before calling

import json
def preflight_input_props(props):
    json.dumps(props, default=_custom_serializer)
    return props

Type guard

def is_json_safe(value, _seen=None):\n    _seen = _seen or set()\n    if id(value) in _seen:\n        return False\n    if isinstance(value, (str, int, float, bool, type(None))):\n        return True\n    _seen.add(id(value))\n    if isinstance(value, dict):\n        return all(is_json_safe(v, _seen) for v in value.values())\n    if isinstance(value, (list, tuple)):\n        return all(is_json_safe(v, _seen) for v in value)\n    return False

Try / catch

try:\n    client.render_media(...)\nexcept RemotionInvalidArgumentException as e:\n    log.error('inputProps serialization failed: %s', e.__cause__)\n    raise

Prevention

When it happens

Trigger: Passing render inputProps that contain circular references, datetime/Decimal/set/object instances that the custom serializer cannot convert, or values that exceed Python's recursion limits.

Common situations: Passing SQLAlchemy/Pydantic/Django model instances directly; nested objects referencing their parents; sets instead of lists; Decimal from DB; large nested dataclasses.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/004ebe7766ce6838. Report an issue: GitHub.