{"record":{"id":"f9d04c74947af827","repo":"apache/beam","slug":"configured-topic-arn-does-not-exist","errorCode":null,"errorMessage":"Configured topic ARN '{}' does not exist.","messagePattern":"Configured topic ARN '(.+?)' does not exist\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/sns/SnsIO.java","lineNumber":186,"sourceCode":"      checkArgument(getPublishRequestBuilder() != null, \"withPublishRequestBuilder() is required\");\n\n      AwsOptions awsOptions = input.getPipeline().getOptions().as(AwsOptions.class);\n      checkArgument(getClientConfiguration() != null, \"withClientConfiguration() is required\");\n      ClientBuilderFactory.validate(awsOptions, getClientConfiguration());\n      if (getTopicArn() != null) {\n        checkArgument(checkTopicExists(awsOptions), \"Topic arn %s does not exist\", getTopicArn());\n      }\n\n      return input.apply(ParDo.of(new SnsWriterFn<>(this)));\n    }\n\n    private boolean checkTopicExists(AwsOptions options) {\n      try (SnsClient client = buildClient(options)) {\n        client.getTopicAttributes(b -> b.topicArn(getTopicArn()));\n        return true;\n      } catch (NotFoundException | InvalidParameterException e) {\n        LoggerFactory.getLogger(Write.class)\n            .warn(\"Configured topic ARN '{}' does not exist.\", getTopicArn(), e);\n        return false;\n      }\n    }\n\n    private SnsClient buildClient(AwsOptions options) {\n      return ClientBuilderFactory.buildClient(\n          options.as(AwsOptions.class), SnsClient.builder(), getClientConfiguration());\n    }\n\n    static class SnsWriterFn<T> extends DoFn<T, PublishResponse> {\n      private static final Logger LOG = LoggerFactory.getLogger(SnsWriterFn.class);\n      private static final Counter SNS_WRITE_FAILURES =\n          Metrics.counter(SnsWriterFn.class, \"SNS_Write_Failures\");\n\n      private final Write<T> spec;\n      private transient SnsClient producer;\n\n      SnsWriterFn(Write<T> spec) {","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/sns/SnsIO.java#L168-L204","documentation":"SnsIO Write's expand() validates that the configured topic ARN actually exists by calling getTopicAttributes. When AWS responds with NotFoundException or InvalidParameterException, it logs this warning and returns false, which leads the sink to fail with an explicit 'topic does not exist' error instead of an opaque AWS error at write time.","triggerScenarios":"Writing with SnsIO.write().to(topicArn) where the ARN is misspelled, points to another region, references a deleted topic, or is formatted with wrong account/region parts so SNS returns NotFoundException.","commonSituations":"Typos in ARN; cross-region topic (client built for wrong region); topic deleted between pipeline assembly and run; using a topic name instead of a full ARN; wrong AWS account.","solutions":["Verify the ARN format: arn:aws:sns:<region>:<account-id>:<topic-name> and correct any typos","Ensure the SNS client region (via AwsOptions) matches the topic's region","Recreate the topic if it was deleted, or point the sink at the existing topic","Confirm the caller has sns:GetTopicAttributes permission (though permission errors surface differently)"],"exampleFix":"// before\nSnsIO.<String>write().to(\"arn:aws:sns:us-east-1:123456789012:topc\")\n// after (corrected name + matching region)\nSnsIO.<String>write().to(\"arn:aws:sns:us-east-1:123456789012:my-topic\")\n  .withSnsClientProvider(Region.US_EAST_1);","handlingStrategy":"validation","validationCode":"// validate the ARN before building the pipeline\nboolean exists = false;\ntry (SnsClient c = SnsClient.create()) {\n  c.getTopicAttributes(b -> b.topicArn(topicArn));\n  exists = true;\n} catch (NotFoundException | InvalidParameterException e) { /* does not exist */ }\nif (!exists) throw new IllegalArgumentException(\"Topic not found: \" + topicArn);","typeGuard":"static boolean isValidTopicArn(String arn) {\n  return arn != null && arn.matches(\"^arn:aws:sns:[a-z0-9-]+:\\\\d{12}:.+ $\");\n}","tryCatchPattern":"try {\n  snsClient.getTopicAttributes(b -> b.topicArn(arn));\n} catch (NotFoundException e) {\n  throw new IllegalArgumentException(\"Topic does not exist (check region/account): \" + arn, e);\n}","preventionTips":["Store ARNs in config validated at deploy time","Keep client region and topic region consistent","Verify topic existence right before launching the pipeline","Check sns:GetTopicAttributes permissions in the pipeline role"],"tags":["sns","aws","arn","topic"],"backgroundTag":"resource-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}