remotion-dev/remotion · error · error

could not parse Lambda response: %w

Error message

could not parse Lambda response: %w

What it means

Returned by invokeRenderLambda() in lambda-go when json.Unmarshal fails to parse the Lambda function's response payload into RemotionRenderResponse. This means the Lambda ran but returned a payload whose shape does not match the Go struct (missing required fields, type mismatches, or non-JSON output like an error stack trace).

Source

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

	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)

	if responseMarshallingError != nil {
		return nil, fmt.Errorf("could not parse Lambda response: %w", responseMarshallingError)
	}

	return &renderResponseOutput, nil
}

func invokeRenderProgressLambda(config RenderConfig) (*RenderProgress, error) {

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

	internalParams, validateError := constructGetProgressInternals(&config)

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Inspect invocationResult.Payload (capture it before unmarshalling) to see the actual bytes the Lambda returned.
  2. Confirm the deployed Lambda version matches the Go SDK version you imported.
  3. Check CloudWatch Logs for the function to see why it returned a non-standard payload.

Example fix

// before
resp, err := lambda_go_sdk.RenderMedia(opts)
if err != nil { log.Fatal(err) } // opaque "could not parse Lambda response"

// after (debug the raw payload)
result, invokeErr := svc.Invoke(ctx, payload)
log.Printf("raw payload: %s", string(result.Payload)) // reveals HTML, error JSON, or version-mismatched schema
var resp RemotionRenderResponse
if err := json.Unmarshal(result.Payload, &resp); err != nil { log.Fatal(err) }
Defensive patterns

Strategy: try-catch

Validate before calling

// Version alignment check at build time: assert the Go SDK version matches the deployed Lambda version.
// Deploy the Lambda via the same @remotion/lambda version the Go SDK was generated against.

Try / catch

result, invokeErr := svc.Invoke(ctx, payload)
if invokeErr != nil { return invokeErr }
var resp RemotionRenderResponse
if err := json.Unmarshal(result.Payload, &resp); err != nil {
  // surface the raw payload for diagnosis
  return fmt.Errorf("unmarshal failed (%w); raw payload: %s", err, string(result.Payload))
}

Prevention

When it happens

Trigger: The Lambda function failed internally and returned an error object/string instead of a render response; a version mismatch between the Go SDK's RemotionRenderResponse struct and the deployed Lambda's output schema; the function returning HTML or a plain error string.

Common situations: The deployed Lambda is an older/newer version than the Go SDK expects (schema drift); the Lambda crashed and returned a runtime error payload; you pointed the Go SDK at a non-Remotion Lambda by mistake.

Related errors


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