anomalyco/sst · error · VisibleError

The provided ARN "${arn}" is not a Lambda function ARN.

Error message

The provided ARN "${arn}" is not a Lambda function ARN.

What it means

parseFunctionArn validates that a user-supplied string is a well-formed Lambda function ARN (arn:...:function:name). It throws a VisibleError when the string does not start with 'arn:' or has no function-name segment at index 6.

Source

Thrown at platform/src/components/aws/helpers/arn.ts:8

import { aws } from "../..";
import { VisibleError } from "../../error";

export function parseFunctionArn(arn: string) {
  // arn:aws:lambda:region:account-id:function:function-name
  const functionName = arn.split(":")[6];
  if (!arn.startsWith("arn:") || !functionName)
    throw new VisibleError(
      `The provided ARN "${arn}" is not a Lambda function ARN.`,
    );
  return { functionName };
}

export function splitQualifiedFunctionArn(arn: string) {
  // Unqualified: arn:aws:lambda:region:account-id:function:function-name (7 parts)
  // Qualified:   arn:aws:lambda:region:account-id:function:function-name:alias-or-version (8 parts)
  const parts = arn.split(":");
  if (parts.length <= 7) {
    return { unqualifiedArn: arn, qualifier: undefined };
  }
  return {
    unqualifiedArn: parts.slice(0, 7).join(":"),
    qualifier: parts[7],
  };
}

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Use the full 7-segment form: arn:aws:lambda:region:account-id:function:function-name
  2. If you only have the name, construct the ARN with the correct region and account ID
  3. Check the source of the ARN string (e.g. CloudFormation export, env var) for truncation or whitespace

Example fix

// before
Function.fromFunctionArn(stack, "Fn", "my-function");
// after
Function.fromFunctionArn(stack, "Fn", "arn:aws:lambda:us-east-1:123456789012:function:my-function");
Defensive patterns

Strategy: validation

Validate before calling

const LAMBDA_ARN = /^arn:aws[a-zA-Z-]*:lambda:[^:]+:\d{12}:function:.+$/;
if (!LAMBDA_ARN.test(arn)) throw new Error(`Not a Lambda ARN: ${arn}`);

Type guard

function isLambdaArn(v: string): boolean {
  return /^arn:aws[a-zA-Z-]*:lambda:[^:]+:\d{12}:function:.+$/.test(v);
}

Try / catch

try {
  const { functionName } = parseFunctionArn(arn);
} catch (e) {
  throw new Error(`Failed to parse Lambda ARN "${arn}": ${(e as Error).message}`);
}

Prevention

When it happens

Trigger: Calling Function.fromFunctionArn (or a subscriber expecting an ARN) with a function name, a URL, a partial ARN missing the function-name field, or a non-Lambda ARN.

Common situations: Passing a function name instead of its ARN, copying an ARN for a lambda version/alias incorrectly, referencing an S3 or IAM ARN by mistake, region/account segments omitted.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/80eb198f634168e2. Report an issue: GitHub.