{"record":{"id":"004ebe7766ce6838","repo":"remotion-dev/remotion","slug":"error-serializing-inputprops-check-for-circular-r","errorCode":null,"errorMessage":"Error serializing InputProps. Check for circular references or invalid data types in the input properties.","messagePattern":"Error serializing InputProps\\. Check for circular references or invalid data types in the input properties\\.","errorType":"exception","errorClass":"RemotionInvalidArgumentException","httpStatus":null,"severity":"error","filePath":"packages/lambda-python/remotion_lambda/remotionclient.py","lineNumber":428,"sourceCode":"\n            if self._needs_upload(payload_size, render_type):\n                hash_value = self._generate_hash(payload)\n                bucket_name = self._get_or_create_bucket()\n                key = self._input_props_key(hash_value)\n\n                self._upload_to_s3(bucket_name, key, payload)\n\n                return {\n                    'type': 'bucket-url',\n                    'hash': hash_value,\n                    'bucketName': bucket_name,\n                }\n            return {\n                'type': 'payload',\n                'payload': payload if payload not in ('', 'null') else json.dumps({}),\n            }\n        except (TypeError, OverflowError) as error:\n            raise RemotionInvalidArgumentException(\n                'Error serializing InputProps. Check for circular '\n                + 'references or invalid data types in the input properties.'\n            ) from error\n        except ClientError as e:\n            raise e\n\n    def _create_lambda_client(self) -> Any: # Returns a Lambda client type\n        \"\"\"Creates and returns a boto3 Lambda client.\"\"\"\n        return self._create_boto_client('lambda')\n\n    def _find_json_objects(self, input_string: str) -> List[str]: # Added type hints\n        \"\"\"Finds and returns a list of complete JSON object strings.\"\"\"\n        objects: List[str] = []\n        depth = 0\n        start_index = 0\n\n        for i, char in enumerate(input_string):\n            if char == '{':","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-python/remotion_lambda/remotionclient.py#L410-L446","documentation":"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.","triggerScenarios":"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.","commonSituations":"Passing SQLAlchemy/Pydantic/Django model instances directly; nested objects referencing their parents; sets instead of lists; Decimal from DB; large nested dataclasses.","solutions":["Pre-serialize inputProps with json.dumps(..., default=str) locally to surface the offending value.","Convert non-serializable types (datetime->isoformat, Decimal->float, set->list) before rendering.","Break circular references before passing data; use plain dicts/lists of primitives.","If using custom objects, implement a conversion to plain dict/list/scalar before calling render."],"exampleFix":"// before\ninput_props = {'item': some_sqlalchemy_model, 'parent': container}\ninput_props['parent']['child'] = input_props  # circular\nclient.render_media(comp, input_props=input_props)\n\n# after\ninput_props = {\n    'item': {\n        'id': some_sqlalchemy_model.id,\n        'name': some_sqlalchemy_model.name,\n    }\n}\nclient.render_media(comp, input_props=input_props)","handlingStrategy":"type-guard","validationCode":"import json\ndef preflight_input_props(props):\n    json.dumps(props, default=_custom_serializer)\n    return props","typeGuard":"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","tryCatchPattern":"try:\\n    client.render_media(...)\\nexcept RemotionInvalidArgumentException as e:\\n    log.error('inputProps serialization failed: %s', e.__cause__)\\n    raise","preventionTips":["Convert datetime/Decimal/set/numpy values to native primitives before rendering.","Break circular references in nested objects.","Pre-serialize inputProps with json.dumps to surface the offending value locally."],"tags":["python","serialization","input-props","lambda","json"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}