{"record":{"id":"b6d1ebf7459430dc","repo":"apache/beam","slug":"invalid-host-port-in-bigtableconfig","errorCode":null,"errorMessage":"Invalid host/port in BigtableConfig ","messagePattern":"Invalid host/port in BigtableConfig ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableConfigTranslator.java","lineNumber":118,"sourceCode":"\n    return buildBigtableDataSettings(config, pipelineOptions).build();\n  }\n\n  private static BigtableDataSettings.Builder buildBigtableDataSettings(\n      BigtableConfig config, PipelineOptions pipelineOptions) throws IOException {\n    BigtableDataSettings.Builder dataBuilder;\n    boolean emulator = false;\n    if (!Strings.isNullOrEmpty(config.getEmulatorHost())) {\n      emulator = true;\n      String hostAndPort = config.getEmulatorHost();\n      try {\n        int lastIndexOfCol = hostAndPort.lastIndexOf(\":\");\n        int port = Integer.parseInt(hostAndPort.substring(lastIndexOfCol + 1));\n        dataBuilder =\n            BigtableDataSettings.newBuilderForEmulator(\n                hostAndPort.substring(0, lastIndexOfCol), port);\n      } catch (NumberFormatException | IndexOutOfBoundsException ex) {\n        throw new RuntimeException(\"Invalid host/port in BigtableConfig \" + hostAndPort);\n      }\n    } else {\n      dataBuilder = BigtableDataSettings.newBuilder();\n    }\n\n    // Configure target\n    dataBuilder\n        .setProjectId(Objects.requireNonNull(config.getProjectId().get()))\n        .setInstanceId(Objects.requireNonNull(config.getInstanceId().get()));\n    if (config.getAppProfileId() != null\n        && !Strings.isNullOrEmpty(config.getAppProfileId().get())) {\n      dataBuilder.setAppProfileId(Objects.requireNonNull(config.getAppProfileId().get()));\n    }\n\n    // Skip resetting the credentials if it's connected to an emulator\n    if (!emulator) {\n      if (pipelineOptions.as(GcpOptions.class).getGcpCredential() != null) {\n        dataBuilder","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableConfigTranslator.java#L100-L136","documentation":"When a Bigtable emulator host:port is configured, buildBigtableDataSettings parses it as host and port. If the string after the last ':' is not a valid integer port (or the string has no host part at all), the NumberFormatException/IndexOutOfBoundsException is rethrown as this RuntimeException.","triggerScenarios":"Setting the Bigtable config's hostAndPort (emulator target) to a malformed value like \"localhost\" (no port), \"localhost:notaport\", or \"::bad\" and then translating the config into BigtableDataSettings.","commonSituations":"Typo in emulator endpoint; environment variable for the emulator host missing its port; copy-paste dropping the :8086; wrong variable interpolated into the config.","solutions":["Fix the emulator address to 'host:port' format, e.g. \"localhost:8086\", in your BigtableConfig/executor config.","Validate the endpoint before building: split on ':' and check Integer.parseInt succeeds.","If you meant a real Bigtable instance, remove the emulator host/port so the code takes the BigtableDataSettings.newBuilder() path."],"exampleFix":"// before\nbuilder.setHostAndPort(\"localhost\"); // throws\n// after\nbuilder.setHostAndPort(\"localhost:8086\");","handlingStrategy":"validation","validationCode":"String[] parts = hostAndPort.split(\":\");\nif (parts.length != 2 || parts[0].isEmpty()) throw new IllegalArgumentException(\"Emulator must be host:port\");\nint port = Integer.parseInt(parts[1]); // throws clear NumberFormatException","typeGuard":"boolean isValidHostPort(String s) { int i = s.lastIndexOf(':'); if (i <= 0) return false; try { Integer.parseInt(s.substring(i + 1)); return true; } catch (NumberFormatException e) { return false; } }","tryCatchPattern":"try { settings = translator.buildBigtableDataSettings(config, options); } catch (RuntimeException e) { if (e.getMessage().contains(\"Invalid host/port\")) { ... } throw e; }","preventionTips":["Use BigtableEmulatorOptions/helpers or the emulator's documented address localhost:8086.","Validate emulator env vars at job-argument parsing time.","Keep host and port as separate config fields to avoid string parsing."],"tags":["bigtable","config","emulator","port"],"backgroundTag":"invalid-config-value","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"}