remotion-dev/remotion · error
Lambda function unexpectedly does not have context.invokedFu
Error message
Lambda function unexpectedly does not have context.invokedFunctionArn
What it means
The Remotion Lambda handler (routine) runs inside AWS Lambda and expects context.invokedFunctionArn to identify the function's ARN, from which the AWS account ID is derived. If it is missing, the invocation did not come through a normal AWS Lambda runtime. The error guards against invoking the handler outside the real Lambda environment.
Source
Thrown at packages/lambda/src/functions/index.ts:40
export const routine = async (
params: ServerlessPayload<AwsProvider>,
responseStream: ResponseStream,
context: LambdaRequestContext,
): Promise<void> => {
const responseWriter = streamWriter(responseStream);
const buffered =
params.type === ServerlessRoutines.info ||
params.type === ServerlessRoutines.start ||
params.type === ServerlessRoutines.compositions;
try {
process.env.__RESERVED_IS_INSIDE_REMOTION_LAMBDA = 'true';
setCurrentRequestId(context.awsRequestId);
stopLeakDetection();
if (!context?.invokedFunctionArn) {
throw new Error(
'Lambda function unexpectedly does not have context.invokedFunctionArn',
);
}
const expectedBucketOwner = context.invokedFunctionArn.split(':')[4];
if (!expectedBucketOwner) {
throw new Error('Expected current user ID');
}
await innerHandler({
params,
responseWriter,
context: {
requestId: context.awsRequestId,
expectedBucketOwner,
getRemainingTimeInMillis: () => context.getRemainingTimeInMillis(),
},
providerSpecifics: LambdaClientInternals.awsImplementation,View on GitHub (pinned to b2f4e34732)
Solutions
- Only invoke the Remotion Lambda handler through the real AWS Lambda runtime (aws invoke lambda / console / SDK against the deployed function).
- If testing locally, provide a context stub that includes invokedFunctionArn (and awsRequestId), e.g. invokedFunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:my-func'.
- Verify you are running the built handler served by Remotion's deploy (npx remotion lambda functions deploy), not importing index.ts directly in a plain Node process.
Example fix
// before (local test)
await routine(payload, {awsRequestId: 'req-1'}, ...);
// after
await routine(payload, {
awsRequestId: 'req-1',
invokedFunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:remotion-render'
}, ...); Defensive patterns
Strategy: type-guard
Validate before calling
function isLambdaContext(c: unknown): c is {awsRequestId: string; invokedFunctionArn: string} {
return typeof c === 'object' && c !== null &&
'invokedFunctionArn' in c && typeof (c as any).invokedFunctionArn === 'string' &&
(c as any).invokedFunctionArn.startsWith('arn:aws:lambda:');
} Type guard
function hasInvokedFunctionArn(ctx: unknown): ctx is {invokedFunctionArn: string; awsRequestId: string} {
return typeof (ctx as any)?.invokedFunctionArn === 'string' && (ctx as any).invokedFunctionArn.length > 0;
} Try / catch
try {
await routine(params, context, responseWriter);
} catch (err) {
if ((err as Error).message.includes('invokedFunctionArn')) {
// handler was invoked outside real AWS Lambda; fix invocation
} else throw err;
} Prevention
- Invoke Remotion Lambda handlers only through the deployed AWS Lambda function
- Use realistic ARNs in any local test fixtures
- Do not import the handler module directly into plain Node scripts
When it happens
Trigger: Invoking the bundled Lambda handler function directly (e.g. locally, via a test harness, or a custom integration) with a context object lacking invokedFunctionArn, or with context null/undefined.
Common situations: Testing the handler locally with a hand-rolled context object, invoking through an event source that strips context, or calling the function via an unofficial runtime where AWS does not populate context.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Expected current user ID
- Failed to acquire 2D context for output canvas
- useLogLevel must be used within a LogLevelProvider
- useMountTime must be used within a LogLevelProvider
- This component must be inside a <Series /> component.
AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09).
Data as JSON: /api/errors/e6e52a9c5c8b608f.
Report an issue: GitHub.