{"record":{"id":"d87a3cd79e575e93","repo":"apache/beam","slug":"pubsub-object-name-is-longer-than-255-characters-name","errorCode":null,"errorMessage":"Pubsub object name is longer than 255 characters: {name}","messagePattern":"Pubsub object name is longer than 255 characters: (.+?)","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":244,"sourceCode":"\n  public static final String ENABLE_CUSTOM_PUBSUB_SINK = \"enable_custom_pubsub_sink\";\n  public static final String ENABLE_CUSTOM_PUBSUB_SOURCE = \"enable_custom_pubsub_source\";\n\n  private static void validateProjectName(String project) {\n    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(","sourceCodeStart":226,"sourceCodeEnd":262,"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#L226-L262","documentation":"Pub/Sub resource names may be at most 255 characters (PUBSUB_NAME_MAX_LENGTH). validatePubsubName rejects names longer than this with an IllegalArgumentException so the invalid name never reaches the service.","triggerScenarios":"validatePubsubName is invoked with a name whose length exceeds 255 while constructing a PubsubIO topic or subscription path.","commonSituations":"Accidentally passing the full resource path (projects/p/topics/...) instead of the bare name; programmatically generated names (timestamps + UUIDs) that balloon in size; concatenated environment/stage prefixes.","solutions":["Shorten the name to 255 characters or fewer, keeping the meaningful suffix","Pass only the bare resource name, not the full path","Bound generated names (hash or truncate UUID/timestamp components)","Validate name length before submitting the pipeline"],"exampleFix":"// before\nString name = \"projects/p/topics/\" + topic; // passed to PubsubIO\n// after\nPubsubIO.writeStrings().to(topic); // bare topic name only","handlingStrategy":"validation","validationCode":"if (name.length() > 255) {\n  throw new IllegalArgumentException(\"Pub/Sub name must be at most 255 characters\");\n}","typeGuard":null,"tryCatchPattern":"try { PubsubIO.readStrings().fromTopic(topic); } catch (IllegalArgumentException e) { log.error(\"Pub/Sub name too long: {}\", e.getMessage()); }","preventionTips":["Pass bare names, not full resource paths","Truncate or hash generated name components","Cap name length in name-generation utilities","Review concatenated prefix schemes for name length growth"],"tags":["java","pubsub","naming","validation","length"],"backgroundTag":"value-out-of-range","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"}