Skip to content
Latchkey

AWS Lambda "Runtime.HandlerNotFound" in CI

The Lambda runtime found and loaded your handler module, but the function name after the dot in the Handler setting is not exported from it. The file is right; the export name is wrong.

What this error means

An invoke returns "Runtime.HandlerNotFound: handler.handler is undefined or not exported". The module imported without error, so this is purely a missing or mismatched export.

lambda
{
  "errorType": "Runtime.HandlerNotFound",
  "errorMessage": "index.handler is undefined or not exported"
}

Common causes

The export name does not match the Handler setting

Handler is index.handler, but the module exports main (or default-exports), so the runtime cannot find handler.

ESM vs CommonJS export mismatch

An .mjs handler uses export const handler, but the config or bundler emitted a default export or a CommonJS module.exports shape the runtime does not read as the named export.

How to fix it

Align the export with the Handler value

  1. Read the Handler value: file.exportName.
  2. Ensure the module exports exactly that name.
  3. Re-deploy or re-package and invoke again.
index.mjs
// Handler = index.handler
export const handler = async (event) => { /* ... */ };

Fix the Handler setting instead

If the export must stay named main, point the Handler at it.

template.yaml
Handler: index.main

How to prevent it

  • Keep the exported symbol and the Handler setting identical.
  • Pick one module system (ESM or CJS) per function and be consistent.
  • Add a smoke invoke in CI that asserts the handler is reachable.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →