{"record":{"id":"3b9300d8be1477a7","repo":"apache/beam","slug":"pubsub-topic-is-not-in-projects-project-id-topics-topic-name","errorCode":null,"errorMessage":"Pubsub topic is not in projects/<project_id>/topics/<topic_name> format: {path}","messagePattern":"Pubsub topic is not in projects/<project_id>/topics/<topic_name> format: (.+?)","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":483,"sourceCode":"     */\n    public static PubsubTopic fromPath(String path) {\n      if (path.equals(TOPIC_DEV_NULL_TEST_NAME)) {\n        return new PubsubTopic(PubsubTopic.Type.FAKE, \"\", path);\n      }\n\n      String projectName, topicName;\n\n      Matcher v1beta1Match = V1BETA1_TOPIC_REGEXP.matcher(path);\n      if (v1beta1Match.matches()) {\n        LOG.warn(\n            \"Saw topic in v1beta1 format.  Topics should be in the format \"\n                + \"projects/<project_id>/topics/<topic_name>\");\n        projectName = v1beta1Match.group(1);\n        topicName = v1beta1Match.group(2);\n      } else {\n        Matcher match = TOPIC_REGEXP.matcher(path);\n        if (!match.matches()) {\n          throw new IllegalArgumentException(\n              \"Pubsub topic is not in projects/<project_id>/topics/<topic_name> format: \" + path);\n        }\n        projectName = match.group(1);\n        topicName = match.group(2);\n      }\n\n      projectName =\n          checkArgumentNotNull(\n              projectName, \"Invalid path: project name must be non-null: %s\", path);\n      topicName =\n          checkArgumentNotNull(topicName, \"Invalid path: topic name must be non-null: %s\", path);\n\n      validateProjectName(projectName);\n      validatePubsubName(topicName);\n      return new PubsubTopic(PubsubTopic.Type.NORMAL, projectName, topicName);\n    }\n\n    /**","sourceCodeStart":465,"sourceCodeEnd":501,"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#L465-L501","documentation":"PubsubIO.Read.fromPath requires the topic path to match projects/<project_id>/topics/<topic_name>. If neither the modern nor legacy v1beta1 pattern matches TOPIC_REGEXP, this IllegalArgumentException is thrown describing the expected format.","triggerScenarios":"Calling PubsubIO.read...().fromTopic()/fromPath with a bare topic name (\"mytopic\"), a subscription path (projects/p/subscriptions/s), or a malformed path.","commonSituations":"Passing only the topic short name from configuration; accidentally passing the subscription path to fromTopic; typos in the 'topics' segment.","solutions":["Use the fully qualified path: projects/YOUR_PROJECT/topics/YOUR_TOPIC.","Confirm you aren't passing a subscription path to fromTopic (use fromSubscription instead).","Build the path programmatically: String.format(\"projects/%s/topics/%s\", projectId, topicId)."],"exampleFix":"// before\nPubsubIO.readStrings().fromTopic(\"events\");\n// after\nPubsubIO.readStrings().fromTopic(\"projects/my-project/topics/events\");","handlingStrategy":"validation","validationCode":"static void checkTopicPath(String path) {\n  if (!path.matches(\"projects/[a-zA-Z0-9-_.~%+]+/topics/[a-zA-Z0-9-_.~%+]+\"))\n    throw new IllegalArgumentException(\"Expected projects/<proj>/topics/<name>: \" + path);\n}","typeGuard":"boolean isTopicPath(String p) {\n  return p != null && p.matches(\"projects/[^/]+/topics/[^/]+\");\n}","tryCatchPattern":"try {\n  return PubsubIO.readStrings().fromTopic(topic);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"topics/<topic_name> format\"))\n    throw new ConfigException(\"Topic path must be projects/<proj>/topics/<name>, got: \" + topic, e);\n  throw e;\n}","preventionTips":["Keep full topic paths in configuration","Use a builder helper: topicPath(project, topic)","Don't confuse fromTopic with fromSubscription arguments"],"tags":["java","pubsub","url-format","beam"],"backgroundTag":"invalid-url-format","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"}