apache/beam · error · IllegalStateException

Failed to apply override function for class

Error message

Failed to apply override function for class 

What it means

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.

Solutions

  1. Read the wrapped cause in the IllegalStateException and fix the bug inside your override class's apply() method.
  2. Add validation of the PipelineOptions values your override consumes before using them.
  3. Recompile the override against the same google-cloud-bigtable version used by the Beam GCP connector to avoid API drift.

Example fix

// before
public Builder apply(Builder b, PipelineOptions o) { return b.setNumChannels(o.as(MyOpts.class).getChannels()); } // getChannels null
// after
public Builder apply(Builder b, PipelineOptions o) {
  int ch = MoreObjects.firstNonNull(o.as(MyOpts.class).getChannels(), 10);
  return b.setNumChannels(ch);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// inside your override
Objects.requireNonNull(options.as(MyOpts.class).getChannels(), "channels option required");

Try / catch

try { settings = translator.buildBigtableDataSettings(config, options); } catch (IllegalStateException e) { log.error("Override apply failed; cause: {}", e.getCause(), e); throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/649059ebcf738d6d. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableConfigTranslator.java:192

    BiFunction<BigtableDataSettings.Builder, PipelineOptions, BigtableDataSettings.Builder>
        overrideFunction;
    try {
      overrideFunction =
          InstanceBuilder.ofType(
                  new TypeDescriptor<
                      BiFunction<
                          BigtableDataSettings.Builder,
                          PipelineOptions,
                          BigtableDataSettings.Builder>>() {})
              .fromClassName(override)
              .build();
    } catch (ClassNotFoundException e) {
      throw new IllegalArgumentException("Failed to load class override " + override, e);
    }
    try {
      return overrideFunction.apply(dataBuilder, pipelineOptions);
    } catch (Exception e) {
      throw new IllegalStateException("Failed to apply override function for class " + override, e);
    }
  }

  private static void configureHeaderProvider(
      StubSettings.Builder<?, ?> stubSettings, PipelineOptions pipelineOptions) {

    ImmutableMap.Builder<String, String> headersBuilder =
        ImmutableMap.<String, String>builder()
            .put(
                GrpcUtil.USER_AGENT_KEY.name(),
                Objects.requireNonNull(pipelineOptions.getUserAgent()));

    stubSettings.setHeaderProvider(FixedHeaderProvider.create(headersBuilder.build()));
  }

  private static void configureChannelPool(
      StubSettings.Builder<?, ?> stubSettings, BigtableConfig config) {
    if (config.getChannelCount() != null) {

View on GitHub (pinned to 12126d8942)