{"record":{"id":"7d2f499e66a51323","repo":"apache/beam","slug":"pubsub-topic-s-does-not-exist","errorCode":null,"errorMessage":"Pubsub topic '%s' does not exist.","messagePattern":"Pubsub topic '(.+?)' does not exist\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubIO.java","lineNumber":1414,"sourceCode":"      PubsubOptions psOptions = options.as(PubsubOptions.class);\n\n      // Validate the existence of the topic.\n      ValueProvider<PubsubTopic> topicProvider = getTopicProvider();\n      if (topicProvider != null) {\n        PubsubTopic topic = topicProvider.get();\n        boolean topicExists = true;\n        try (PubsubClient pubsubClient =\n            getPubsubClientFactory()\n                .newClient(getTimestampAttribute(), getIdAttribute(), psOptions)) {\n          topicExists =\n              pubsubClient.isTopicExists(\n                  PubsubClient.topicPathFromName(topic.project, topic.topic));\n        } catch (Exception e) {\n          throw new RuntimeException(e);\n        }\n\n        if (!topicExists) {\n          throw new IllegalArgumentException(\n              String.format(\"Pubsub topic '%s' does not exist.\", topic));\n        }\n      }\n    }\n\n    @Override\n    public void populateDisplayData(DisplayData.Builder builder) {\n      super.populateDisplayData(builder);\n      populateCommonDisplayData(\n          builder, getTimestampAttribute(), getIdAttribute(), getTopicProvider());\n      builder.addIfNotNull(\n          DisplayData.item(\"subscription\", getSubscriptionProvider())\n              .withLabel(\"Pubsub Subscription\"));\n    }\n  }\n\n  private static class ParseReadFailuresToBadRecords\n      extends DoFn<KV<PubsubMessage, EncodableThrowable>, BadRecord> {","sourceCodeStart":1396,"sourceCodeEnd":1432,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubIO.java#L1396-L1432","documentation":"During validation of a PubsubIO.Read transform (when withValidation is enabled), the connector checks that the configured topic actually exists in Cloud Pub/Sub by calling topicPathFromName / topic lookup. If the topic cannot be found, it throws IllegalArgumentException with the topic path in the message. This is a fail-fast check so pipelines do not run and fail at runtime.","triggerScenarios":"Enabling validation on PubsubIO.read...from(topic) where the topic string references a topic that does not exist in the given project (typo, wrong project, or topic deleted before launch).","commonSituations":"Typos in fully-qualified topic names (projects/p/topic), running the pipeline against a different GCP project than where the topic was created, topics deleted between runs, or environment-specific config pointing at staging resources.","solutions":["Verify the topic exists: gcloud pubsub topics list --project=YOUR_PROJECT; create it with gcloud pubsub topics create if missing.","Check the project segment of the topic path matches the project where the topic was created.","Fix typos or stale configuration values in the topic string.","If existence checking is unwanted, remove withValidation() so the transform skips this pre-flight check."],"exampleFix":"// before\nPubsubIO.readMessages().from(\"projects/my-proj/topics/myTopc\").applyValidation();\n// after\ngcloud pubsub topics create projects/my-proj/topics/myTopic\nPubsubIO.readMessages().from(\"projects/my-proj/topics/myTopic\").applyValidation();","handlingStrategy":"validation","validationCode":"boolean exists = false;\ntry (PubsubClient client = PubsubClient.newGCloudClient(PubsubClient.topicPathFromName(project, topic).toString())) {\n  exists = client.topicExists(PubsubClient.topicPathFromName(project, topic));\n}\nif (!exists) throw new IllegalArgumentException(\"Topic \" + topic + \" does not exist\");","typeGuard":null,"tryCatchPattern":"try {\n  pipeline.run();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"does not exist\")) {\n    // provision topic or fix config, then retry launch\n  }\n}","preventionTips":["Provision topics with infrastructure-as-code (Terraform/gcloud) before deploying pipelines.","Keep topic names in environment-specific config, validated per environment.","Use fully-qualified topic paths and verify the project segment."],"tags":["java","pubsub","gcp","resource-not-found","validation"],"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-14T16:17:12.679Z"}