remotion-dev/remotion · error · error

could not serialize render parameters: %w

Error message

could not serialize render parameters: %w

What it means

Returned by invokeRenderLambda() in lambda-go when json.Marshal fails to serialize the internal render parameters built by constructRenderInternals(). Marshal fails on unsupported types (channels, functions, circular references) or on a custom MarshalJSON method that returns an error.

Source

Thrown at packages/lambda-go/invocations.go:31

	awsConfig, configError := awsconfig.LoadDefaultConfig(
		context.Background(),
		awsconfig.WithRegion(options.Region),
	)
	if configError != nil {
		return nil, fmt.Errorf("could not load AWS config: %w", configError)
	}
	svc := lambda.NewFromConfig(awsConfig)

	internalParams, validateError := constructRenderInternals(&options)

	if validateError != nil {
		return nil, validateError
	}

	internalParamJsonObject, marshallingError := json.Marshal(internalParams)
	if marshallingError != nil {
		return nil, fmt.Errorf("could not serialize render parameters: %w", marshallingError)
	}

	invocationPayload := &lambda.InvokeInput{
		FunctionName: new(options.FunctionName),
		Payload:      internalParamJsonObject,
	}

	// Invoke Lambda function
	invocationResult, invocationError := svc.Invoke(context.Background(), invocationPayload)

	if invocationError != nil {
		return nil, fmt.Errorf("could not invoke Lambda function %q: %w", options.FunctionName, invocationError)
	}

	// Unmarshal response from Lambda function
	var renderResponseOutput RemotionRenderResponse

	responseMarshallingError := json.Unmarshal(invocationResult.Payload, &renderResponseOutput)

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Inspect the wrapped error (fmt.Printf("%+v", err)) to identify the offending field/type.
  2. Ensure every field on the params struct is a JSON-serializable type (primitives, slices, maps, structs, pointers to those).
  3. Add `json:"-"` tags to non-serializable helper fields (mutexes, channels, function values).

Example fix

// before
type RemotionOptions struct {
    FunctionName string
    OnProgress   func(int) `json:"onProgress"` // cannot marshal a func
}

// after
type RemotionOptions struct {
    FunctionName string
    OnProgress   func(int) `json:"-"`
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate that the options struct is JSON-serializable at startup.
if _, err := json.Marshal(opts); err != nil { log.Fatalf("opts not serializable: %v", err) }

Try / catch

resp, err := lambda_go_sdk.RenderMedia(opts)
if err != nil {
  var jse *json.UnsupportedTypeError
  if errors.As(err, &jse) { /* offending field type */ }
}

Prevention

When it happens

Trigger: A field on RemotionOptions or its internal representation that contains a non-serializable Go value, a circular reference, or a custom MarshalJSON that errors; passing an InputProps struct with unexported fields that JSON tags cannot reach.

Common situations: Extending RemotionOptions with a custom field whose type cannot marshal; embedding a function value or sync.Mutex (which has no JSON representation); a bug in a custom MarshalJSON implementation.

Related errors


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