apache/beam · warning

Could not use the provided `Coder` implementation when…

Error message

Could not use the provided `Coder` implementation when upgrading.Using the default.

What it means

When translating a BigQueryIO Read transform back from its config Row, Beam attempts to restore a serialized custom Coder implementation. If deserialization fails with InvalidClassException (serialized class no longer matches), Beam logs this warning and continues using the transform's default Coder.

Solutions

  1. Regenerate the pipeline with the current SDK so the coder is re-serialized with the current class.
  2. Add/align serialVersionUID on the custom Coder to keep deserialization compatible across versions.
  3. Verify the default Coder fallback produces correct output; if not, explicitly call .setCoder(new YourCoder()) after building the transform.
  4. Pin the Beam SDK version used to serialize and deserialize the pipeline to the same release.

Example fix

// before
public class MyCoder extends CustomCoder<Row> { /* no serialVersionUID */ }
// after
public class MyCoder extends CustomCoder<Row> {
  private static final long serialVersionUID = 1L;
}
Defensive patterns

Strategy: fallback

Validate before calling

try { fromByteArray(coderBytes); } catch (InvalidClassException e) { /* use default coder */ }

Type guard

boolean coderBytesValid(byte[] b) { try { fromByteArray(b); return true; } catch (InvalidClassException e) { return false; } }

Try / catch

try { builder = builder.setCoder((Coder) fromByteArray(coderBytes)); } catch (InvalidClassException e) { LOG.warn(...); /* default coder retained */ }

Prevention

When it happens

Trigger: readTransformFromRow -> fromConfigRow for a BigQueryIO.Read where the 'coder' config field contains bytes serialized by an incompatible class version (InvalidClassException from fromByteArray).

Common situations: SDK version upgrades where a custom Coder class changed between releases; replaying serialized pipeline definitions with a newer Beam version; custom coders without stable serialVersionUID.

Related errors


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

Appendix: source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIOTranslation.java:356

        if (timestampPrecisionBytes != null) {
          builder =
              builder.setDirectReadPicosTimestampPrecision(
                  (TimestampPrecision) fromByteArray(timestampPrecisionBytes));
        }
        Collection<String> selectedFields = configRow.getArray("selected_fields");
        if (selectedFields != null && !selectedFields.isEmpty()) {
          builder.setSelectedFields(StaticValueProvider.of(ImmutableList.of(selectedFields)));
        }
        String rowRestriction = configRow.getString("row_restriction");
        if (rowRestriction != null) {
          builder = builder.setRowRestriction(StaticValueProvider.of(rowRestriction));
        }
        byte[] coderBytes = configRow.getBytes("coder");
        if (coderBytes != null) {
          try {
            builder = builder.setCoder((Coder) fromByteArray(coderBytes));
          } catch (InvalidClassException e) {
            LOG.warn(
                "Could not use the provided `Coder` implementation when upgrading."
                    + "Using the default.");
          }
        }
        String kmsKey = configRow.getString("kms_key");
        if (kmsKey != null) {
          builder = builder.setKmsKey(kmsKey);
        }
        byte[] typeDescriptorBytes = configRow.getBytes("type_descriptor");
        if (typeDescriptorBytes != null) {
          builder = builder.setTypeDescriptor((TypeDescriptor) fromByteArray(typeDescriptorBytes));
        }
        byte[] toBeamRowFnBytes = configRow.getBytes("to_beam_row_fn");
        if (toBeamRowFnBytes != null) {
          builder = builder.setToBeamRowFn((ToBeamRowFunction) fromByteArray(toBeamRowFnBytes));
        }
        byte[] fromBeamRowFnBytes = configRow.getBytes("from_beam_row_fn");
        if (fromBeamRowFnBytes != null) {

View on GitHub (pinned to 12126d8942)