{"record":{"id":"c07281a563f52ca8","repo":"apache/beam","slug":"pubsub-object-name-cannot-start-with-goog-name","errorCode":null,"errorMessage":"Pubsub object name cannot start with goog: {name}","messagePattern":"Pubsub object name cannot start with goog: (.+?)","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":249,"sourceCode":"    Matcher match = PROJECT_ID_REGEXP.matcher(project);\n    if (!match.matches()) {\n      throw new IllegalArgumentException(\n          \"Illegal project name specified in Pubsub subscription: \" + project);\n    }\n  }\n\n  private static void validatePubsubName(String name) {\n    if (name.length() < PUBSUB_NAME_MIN_LENGTH) {\n      throw new IllegalArgumentException(\n          \"Pubsub object name is shorter than 3 characters: \" + name);\n    }\n    if (name.length() > PUBSUB_NAME_MAX_LENGTH) {\n      throw new IllegalArgumentException(\n          \"Pubsub object name is longer than 255 characters: \" + name);\n    }\n\n    if (name.startsWith(\"goog\")) {\n      throw new IllegalArgumentException(\"Pubsub object name cannot start with goog: \" + name);\n    }\n\n    Matcher match = PUBSUB_NAME_REGEXP.matcher(name);\n    if (!match.matches()) {\n      throw new IllegalArgumentException(\n          \"Illegal Pubsub object name specified: \"\n              + name\n              + \" Please see Javadoc for naming rules.\");\n    }\n  }\n\n  /** Populate common {@link DisplayData} between Pubsub source and sink. */\n  private static void populateCommonDisplayData(\n      DisplayData.Builder builder,\n      @Nullable String timestampAttribute,\n      @Nullable String idAttribute,\n      @Nullable ValueProvider<PubsubTopic> topic) {\n    builder","sourceCodeStart":231,"sourceCodeEnd":267,"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#L231-L267","documentation":"PubsubIO.validatePubsubName rejects any Pub/Sub topic or subscription name that starts with \"goog\", because Google reserves such names for its own managed topics/subscriptions. This is a fail-fast guard when user code calls PubsubIO.read/write APIs with an invalid resource name.","triggerScenarios":"Calling PubsubIO.read...().fromTopic()/fromSubscription() or writing with a name whose topic/subscription name component begins with \"goog\" (e.g. projects/my-proj/topics/goog-my-topic), passing validatePubsubName directly, or building a PubsubMessage to a goog-prefixed destination.","commonSituations":"Copying Google's own managed topics (e.g. goog-* system topics) as a template for custom topics; typo'd names; testing with names that mimic Google internal naming.","solutions":["Rename the topic/subscription so its name does not start with \"goog\" (any other prefix is fine, e.g. app-events).","If you intend to read a Google-managed goog-* topic, do not reference it by name via PubsubIO name validation paths; use the full resource path and an API that permits it, or subscribe via the Cloud Console-created subscription instead.","Check the variable feeding fromTopic/fromSubscription for accidental prefixes from config or templating."],"exampleFix":"// before\nPubsubIO.writeStrings().to(\"projects/my-proj/topics/goog-user-events\");\n// after\nPubsubIO.writeStrings().to(\"projects/my-proj/topics/user-events\");","handlingStrategy":"validation","validationCode":"static boolean validPubsubName(String name) {\n  return name != null && name.length() <= 255 && !name.startsWith(\"goog\")\n      && name.matches(\"[a-zA-Z][a-zA-Z0-9-_.~%+]{2,254}\");\n}\n// call before: PubsubIO.writeStrings().to(\"projects/p/topics/\" + name);\nif (!validPubsubName(name)) throw new IllegalArgumentException(\"bad pubsub name: \" + name);","typeGuard":"boolean isSafePubsubName(String name) {\n  return name != null && !name.startsWith(\"goog\") && name.matches(\"[a-zA-Z][a-zA-Z0-9-_.~%+]{2,254}\");\n}","tryCatchPattern":"try {\n  pipeline.apply(PubsubIO.writeStrings().to(topicPath));\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"cannot start with goog\")) {\n    throw new ConfigException(\"Rename topic/subscription; goog* is reserved\", e);\n  }\n  throw e;\n}","preventionTips":["Never name topics/subscriptions with a goog prefix","Keep resource names in config validated once at startup","Centralize topic-name construction in one helper"],"tags":["java","pubsub","naming","beam"],"backgroundTag":"invalid-identifier-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-15T02:17:10.978Z"}