anomalyco/sst · error · VisibleError

The provided ARN "${arn}" is not an SNS Topic ARN.

Error message

The provided ARN "${arn}" is not an SNS Topic ARN.

What it means

parseTopicArn validates that a string is an SNS topic ARN (arn:aws:sns:region:account-id:topic-name). It throws a VisibleError when the string lacks the 'arn:' prefix or a topic-name segment at index 5.

Source

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

  };
}


export function parseBucketArn(arn: string) {
  // arn:aws:s3:::bucket-name
  const bucketName = arn.split(":")[5];
  if (!arn.startsWith("arn:") || !bucketName)
    throw new VisibleError(
      `The provided ARN "${arn}" is not an S3 bucket ARN.`,
    );
  return { bucketName };
}

export function parseTopicArn(arn: string) {
  // arn:aws:sns:region:account-id:topic-name
  const topicName = arn.split(":")[5];
  if (!arn.startsWith("arn:") || !topicName)
    throw new VisibleError(
      `The provided ARN "${arn}" is not an SNS Topic ARN.`,
    );
  return { topicName };
}

export function parseQueueArn(arn: string) {
  // arn:aws:sqs:region:account-id:queue-name
  const [arnStr, , , region, accountId, queueName] = arn.split(":");
  if (arnStr !== "arn" || !queueName)
    throw new VisibleError(
      `The provided ARN "${arn}" is not an SQS Queue ARN.`,
    );
  return {
    queueName,
    queueUrl: `https://sqs.${region}.amazonaws.com/${accountId}/${queueName}`,
  };
}

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Use the full form arn:aws:sns:region:account-id:topic-name
  2. If you have the topic name, construct the ARN with region and account ID
  3. Verify the ARN in the AWS console (SNS > Topics) and copy it exactly

Example fix

// before
parseTopicArn("my-topic");
// after
parseTopicArn("arn:aws:sns:us-east-1:123456789012:my-topic");
Defensive patterns

Strategy: validation

Validate before calling

const TOPIC_ARN = /^arn:aws[a-zA-Z-]*:sns:[^:]+:\d{12}:.+$/;
if (!TOPIC_ARN.test(arn)) throw new Error(`Not an SNS topic ARN: ${arn}`);

Type guard

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

Try / catch

try {
  const { topicName } = parseTopicArn(arn);
} catch (e) {
  throw new Error(`Failed to parse SNS topic ARN "${arn}": ${(e as Error).message}`);
}

Prevention

When it happens

Trigger: Subscribing a function or queue to an SNS topic via ARN where the string is a topic name, a URL, or a truncated ARN.

Common situations: Passing just the topic name, copying an SNS subscription endpoint instead of the topic ARN, missing region/account segments.

Related errors


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