{"record":{"id":"649059ebcf738d6d","repo":"apache/beam","slug":"failed-to-apply-override-function-for-class","errorCode":null,"errorMessage":"Failed to apply override function for class ","messagePattern":"Failed to apply override function for class ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableConfigTranslator.java","lineNumber":192,"sourceCode":"    BiFunction<BigtableDataSettings.Builder, PipelineOptions, BigtableDataSettings.Builder>\n        overrideFunction;\n    try {\n      overrideFunction =\n          InstanceBuilder.ofType(\n                  new TypeDescriptor<\n                      BiFunction<\n                          BigtableDataSettings.Builder,\n                          PipelineOptions,\n                          BigtableDataSettings.Builder>>() {})\n              .fromClassName(override)\n              .build();\n    } catch (ClassNotFoundException e) {\n      throw new IllegalArgumentException(\"Failed to load class override \" + override, e);\n    }\n    try {\n      return overrideFunction.apply(dataBuilder, pipelineOptions);\n    } catch (Exception e) {\n      throw new IllegalStateException(\"Failed to apply override function for class \" + override, e);\n    }\n  }\n\n  private static void configureHeaderProvider(\n      StubSettings.Builder<?, ?> stubSettings, PipelineOptions pipelineOptions) {\n\n    ImmutableMap.Builder<String, String> headersBuilder =\n        ImmutableMap.<String, String>builder()\n            .put(\n                GrpcUtil.USER_AGENT_KEY.name(),\n                Objects.requireNonNull(pipelineOptions.getUserAgent()));\n\n    stubSettings.setHeaderProvider(FixedHeaderProvider.create(headersBuilder.build()));\n  }\n\n  private static void configureChannelPool(\n      StubSettings.Builder<?, ?> stubSettings, BigtableConfig config) {\n    if (config.getChannelCount() != null) {","sourceCodeStart":174,"sourceCodeEnd":210,"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#L174-L210","documentation":"After reflectively loading the settings-override BiFunction, the translator invokes it with the data settings builder and pipeline options. Any exception the override function itself throws is wrapped in this IllegalStateException, distinguishing runtime failure inside the override from class-loading failure.","triggerScenarios":"The loaded override class's apply(builder, options) throws — e.g. it reads invalid pipeline options, calls a stub builder method with bad parameters, or hits any runtime error inside its configuration logic.","commonSituations":"Override logic assuming options values that are unset/invalid; override written against a different google-cloud-bigtable version whose builder API changed; bugs in custom override code.","solutions":["Read the wrapped cause in the IllegalStateException and fix the bug inside your override class's apply() method.","Add validation of the PipelineOptions values your override consumes before using them.","Recompile the override against the same google-cloud-bigtable version used by the Beam GCP connector to avoid API drift."],"exampleFix":"// before\npublic Builder apply(Builder b, PipelineOptions o) { return b.setNumChannels(o.as(MyOpts.class).getChannels()); } // getChannels null\n// after\npublic Builder apply(Builder b, PipelineOptions o) {\n  int ch = MoreObjects.firstNonNull(o.as(MyOpts.class).getChannels(), 10);\n  return b.setNumChannels(ch);\n}","handlingStrategy":"try-catch","validationCode":"// inside your override\nObjects.requireNonNull(options.as(MyOpts.class).getChannels(), \"channels option required\");","typeGuard":null,"tryCatchPattern":"try { settings = translator.buildBigtableDataSettings(config, options); } catch (IllegalStateException e) { log.error(\"Override apply failed; cause: {}\", e.getCause(), e); throw e; }","preventionTips":["Keep override.apply() logic minimal and defensively validate options.","Pin the google-cloud-bigtable version to match the Beam GCP SDK.","Unit-test the override function directly with a mock builder and options."],"tags":["bigtable","reflection","override"],"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"}