{"record":{"id":"ce46c8dbd51eb116","repo":"apache/beam","slug":"pubsub-subscription-is-not-in-projects-project-id","errorCode":null,"errorMessage":"Pubsub subscription is not in projects/<project_id>/subscriptions/<subscription_name> format: {path}","messagePattern":"Pubsub subscription is not in projects/<project_id>/subscriptions/<subscription_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":328,"sourceCode":"    public static PubsubSubscription fromPath(String path) {\n      if (path.startsWith(SUBSCRIPTION_RANDOM_TEST_PREFIX)\n          || path.startsWith(SUBSCRIPTION_STARTING_SIGNAL)) {\n        return new PubsubSubscription(PubsubSubscription.Type.FAKE, \"\", path);\n      }\n\n      String projectName, subscriptionName;\n\n      Matcher v1beta1Match = V1BETA1_SUBSCRIPTION_REGEXP.matcher(path);\n      if (v1beta1Match.matches()) {\n        LOG.warn(\n            \"Saw subscription in v1beta1 format. Subscriptions should be in the format \"\n                + \"projects/<project_id>/subscriptions/<subscription_name>\");\n        projectName = v1beta1Match.group(1);\n        subscriptionName = v1beta1Match.group(2);\n      } else {\n        Matcher match = SUBSCRIPTION_REGEXP.matcher(path);\n        if (!match.matches()) {\n          throw new IllegalArgumentException(\n              \"Pubsub subscription is not in \"\n                  + \"projects/<project_id>/subscriptions/<subscription_name> format: \"\n                  + path);\n        }\n        projectName = match.group(1);\n        subscriptionName = match.group(2);\n      }\n\n      projectName =\n          checkArgumentNotNull(\n              projectName, \"Invalid path: project name must be non-null: %s\", path);\n      subscriptionName =\n          checkArgumentNotNull(\n              subscriptionName, \"Invalid path: subscription name must be non-null: %s\", path);\n\n      validateProjectName(projectName);\n      validatePubsubName(subscriptionName);\n      return new PubsubSubscription(PubsubSubscription.Type.NORMAL, projectName, subscriptionName);","sourceCodeStart":310,"sourceCodeEnd":346,"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#L310-L346","documentation":"PubsubIO.Read.fromPath requires the subscription path to match projects/<project_id>/subscriptions/<subscription_name>. If the v1beta1 legacy formats also fail and SUBSCRIPTION_REGEXP doesn't match, this IllegalArgumentException is thrown describing the expected format.","triggerScenarios":"Calling PubsubIO.read...().fromSubscription()/fromPath with a bare subscription name (\"mysub\"), a topic path (projects/p/topics/t), a path with extra segments, or wrong separators.","commonSituations":"Copy/pasting just the subscription name from the Cloud Console; swapping topic and subscription strings; constructing paths with a '/subscriptions/' misspelling.","solutions":["Use the fully qualified path: projects/YOUR_PROJECT/subscriptions/YOUR_SUBSCRIPTION.","Verify you didn't pass a topic path to fromSubscription (use fromTopic for projects/.../topics/...).","Prefer the typed helpers fromSubscription(String) which build the path for you from project and subscription id if available."],"exampleFix":"// before\nPubsubIO.readStrings().fromSubscription(\"my-subscription\");\n// after\nPubsubIO.readStrings().fromSubscription(\"projects/my-project/subscriptions/my-subscription\");","handlingStrategy":"validation","validationCode":"static void checkSubscriptionPath(String path) {\n  if (!path.matches(\"projects/[a-zA-Z0-9-_.~%+]+/subscriptions/[a-zA-Z0-9-_.~%+]+\"))\n    throw new IllegalArgumentException(\"Expected projects/<proj>/subscriptions/<name>: \" + path);\n}","typeGuard":"boolean isSubscriptionPath(String p) {\n  return p != null && p.matches(\"projects/[^/]+/subscriptions/[^/]+\");\n}","tryCatchPattern":"try {\n  return PubsubIO.readStrings().fromSubscription(sub);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"subscriptions/<subscription_name> format\"))\n    throw new ConfigException(\"Subscription path must be projects/<proj>/subscriptions/<name>, got: \" + sub, e);\n  throw e;\n}","preventionTips":["Always store the fully qualified path, not the short name","Build paths with String.format(\"projects/%s/subscriptions/%s\", proj, name)","Double-check topic vs subscription config keys"],"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"}