apache/seatunnel · error · UnsupportedOperationException
File format 'canal_json' does not support reading.
Error message
File format 'canal_json' does not support reading.
What it means
The CANAL_JSON FileFormat enum member only implements a write strategy (CanalJsonWriteStrategy). Calling getReadStrategy() on it throws UnsupportedOperationException because canal-json files cannot be read back as a regular file source format.
Source
Thrown at seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/config/FileFormat.java:148
@Override
public WriteStrategy getWriteStrategy(FileSinkConfig fileSinkConfig) {
return new BinaryWriteStrategy(fileSinkConfig);
}
@Override
public ReadStrategy getReadStrategy() {
return new BinaryReadStrategy();
}
},
CANAL_JSON("canal_json") {
@Override
public WriteStrategy getWriteStrategy(FileSinkConfig fileSinkConfig) {
return new CanalJsonWriteStrategy(fileSinkConfig);
}
@Override
public ReadStrategy getReadStrategy() {
throw new UnsupportedOperationException(
"File format 'canal_json' does not support reading.");
}
},
DEBEZIUM_JSON("debezium_json") {
@Override
public WriteStrategy getWriteStrategy(FileSinkConfig fileSinkConfig) {
return new DebeziumJsonWriteStrategy(fileSinkConfig);
}
@Override
public ReadStrategy getReadStrategy() {
throw new UnsupportedOperationException(
"File format 'debezium_json' does not support reading.");
}
},
MAXWELL_JSON("maxwell_json") {
@Override
public WriteStrategy getWriteStrategy(FileSinkConfig fileSinkConfig) {View on GitHub (pinned to cf67b549a7)
Solutions
- Use a format that supports reading (e.g. text, csv, json, parquet, orc) for the file source.
- Use the MySQL-CDC connector to consume canal-style change data instead of a file source.
- Wrap the format resolution with a capability check (FileFormat supports getReadStrategy) before selecting the format.
- If write-only output is what you need, keep canal_json only on sink configs.
Example fix
// before
source {
LocalFile {
format = "canal_json"
}
}
// after
source {
LocalFile {
format = "json"
}
} Defensive patterns
Strategy: validation
Validate before calling
FileFormat fmt = FileFormat.valueOf(config.get("format"));
try {
fmt.getReadStrategy();
} catch (UnsupportedOperationException e) {
throw new IllegalArgumentException("Format " + fmt + " cannot be used as a file source");
} Type guard
boolean isReadable(FileFormat fmt) {
try { fmt.getReadStrategy(); return true; }
catch (UnsupportedOperationException e) { return false; }
} Try / catch
try {
sourceConfig.getFormat().getReadStrategy();
} catch (UnsupportedOperationException e) {
log.error("This file format supports writing only; switch to a readable format", e);
throw new IllegalArgumentException(e);
} Prevention
- Check format read/write capability in docs before choosing it for a source.
- Never use CDC JSON formats (canal_json/debezium_json/maxwell_json) in source jobs.
- Add a config linter that probes FileFormat.getReadStrategy for sources.
- When migrating sink configs to sources, audit the format field first.
When it happens
Trigger: Configuring a file source (or any code path that resolves a ReadStrategy) with format = "canal_json"; FileFormat.valueOf(...).getReadStrategy() is invoked during source initialization.
Common situations: Copy-pasting a sink config into a source job; assuming CDC JSON formats are bidirectional; docs/examples mismatch across SeaTunnel versions.
Related errors
- File format 'debezium_json' does not support reading.
- File format 'maxwell_json' does not support reading.
- FORMAT_NOT_SUPPORT
- File format 'markdown' does not support writing.
- FILE_TYPE_INVALID
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/5d8378dd83ebb1ad.
Report an issue: GitHub.