apache/beam · error · IllegalArgumentException
Format not supported. Only supported formats are
Error message
Format %s not supported. Only supported formats are %s
What it means
PubsubWriteSchemaTransformProvider.from() throws IllegalArgumentException when the configuration's format is null or not in VALID_DATA_FORMATS (e.g. RAW, JSON, AVRO). This validates the Pubsub write SchemaTransform configuration before building the transform. The message lists the valid formats so the caller can correct it.
Solutions
- Set format to one of the supported values (uppercase-insensitive): check VALID_DATA_FORMATS in the provider, e.g. "RAW", "JSON", "AVRO".
- Fix the spelling/case in your YAML or config payload and redeploy.
- If you need a format not in the list, transform your data to a supported format upstream (e.g. encode to JSON bytes yourself).
Example fix
// before
PubsubWriteSchemaTransformConfiguration.newBuilder().setFormat("text").build();
// after
PubsubWriteSchemaTransformConfiguration.newBuilder().setFormat("JSON").build(); Defensive patterns
Strategy: validation
Validate before calling
if (format == null || !Set.of("RAW","JSON","AVRO").contains(format.toUpperCase())) throw new IllegalArgumentException("unsupported format: " + format); Type guard
null
Try / catch
try { provider.from(config); } catch (IllegalArgumentException e) { LOG.error("config error: {}", e.getMessage()); } Prevention
- Keep a constants enum of supported formats and validate configs at load time.
- Snapshot-test YAML configs against the provider's VALID_DATA_FORMATS.
- Fail fast in CI by constructing all transforms before submitting pipelines.
When it happens
Trigger: Configuring a Pubsub write SchemaTransform (e.g. from YAML/SQL runner) with format "json " (case handled via toUpperCase, but typos like "text", "csv", "proto" are not), or omitting format entirely.
Common situations: YAML pipeline configs with a mistyped format value; documentation drift after supported formats changed; dynamic config from a variable containing an empty or legacy format string.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- A schema was provided without a data format (or viceversa)…
- Can't set both the topic and the subscription for a…
- Configuration schema provided does not match expected
- Could not determine port for pubsub root url
- Could not parse pubsub root url
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8571ed830cf2e2d5.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubWriteSchemaTransformProvider.java:144
.get(OUTPUT_TAG)
.output(new PubsubMessage(valueMapper.apply(payloadRow), messageAttributes));
} catch (Exception e) {
if (useErrorOutput) {
receiver
.get(ERROR_TAG)
.output(Row.withSchema(errorSchema).addValues(e.toString(), row).build());
} else {
throw e;
}
}
}
}
@Override
public SchemaTransform from(PubsubWriteSchemaTransformConfiguration configuration) {
String format = checkArgumentNotNull(configuration.getFormat(), "Format must be specified");
if (!VALID_DATA_FORMATS.contains(format.toUpperCase())) {
throw new IllegalArgumentException(
String.format(
"Format %s not supported. Only supported formats are %s", format, VALID_FORMATS_STR));
}
return new PubsubWriteSchemaTransform(configuration);
}
private static class PubsubWriteSchemaTransform extends SchemaTransform implements Serializable {
final PubsubWriteSchemaTransformConfiguration configuration;
PubsubWriteSchemaTransform(PubsubWriteSchemaTransformConfiguration configuration) {
this.configuration = configuration;
}
@Override
public PCollectionRowTuple expand(PCollectionRowTuple input) {
PubsubWriteSchemaTransformConfiguration.ErrorHandling errorHandling =
configuration.getErrorHandling();
String errorOutput = errorHandling == null ? null : errorHandling.getOutput();View on GitHub (pinned to 12126d8942)