apache/beam · error · GoogleJsonResponseException
${msg}
Error message
${msg} What it means
checkSchemaPredicate throws a GoogleJsonResponseException with HTTP 412 Precondition Failed when the predicate is false. It is the fake's way of reporting BigQuery precondition failures (typically schema conflicts) with a caller-supplied message.
Solutions
- Make the schema change BigQuery-compatible (add optional fields, never change/remove existing field types or modes)
- Fetch the current table schema first and merge the new fields with the existing ones
- Catch GoogleJsonResponseException and inspect the 412 status plus message to identify the violated precondition
Example fix
// before
schema.update(Set.of(Field.newBuilder("f", LegacySQLTypeName.INTEGER).build())); // 412
// after
// keep existing field 'f', only add new nullable fields
TableSchema merged = mergeFields(existingSchema, newFields);
service.updateTableSchema(tableRef, merged); Defensive patterns
Strategy: try-catch
Validate before calling
// Compare your new schema against the fetched one before updating
Table current = service.getTable(tableRef);
for (Field f : newFields) {
Field existing = current.getSchema().getFields().stream()
.filter(x -> x.getName().equals(f.getName())).findFirst().orElse(null);
if (existing != null && (existing.getType() != f.getType() || existing.getMode() != f.getMode())) {
throw new IllegalArgumentException("illegal schema change on field: " + f.getName());
}
} Try / catch
try {
service.updateTableSchema(tableRef, newSchema);
} catch (GoogleJsonResponseException e) {
if (e.getStatusCode() == 412) {
throw new SchemaPreconditionFailedException(e.getDetails(), e);
}
throw e;
} Prevention
- Only add nullable fields; never alter existing field types or modes
- Fetch and merge current schema before update
- Test schema migrations against the fake before running against real BigQuery
When it happens
Trigger: checkSchemaChangesProtos detecting an incompatible schema change (e.g. modifying a REQUIRED/REPEATED field, changing a field type) via update/patch table schema calls.
Common situations: Tests or code updating a table schema in a way BigQuery would reject: narrowing a field type, making an optional field required, changing mode.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- bigquery write error
- Both a query and an output type of 'BEAM_ROW' were…
- Conflicting field modes for field
- Conflicting field types for field
- Converting BigQuery type
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/10c9ae00e1d4e40c.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/testing/FakeDatasetService.java:441
throwNotFound("Tried to get a table %s, but no such table existed", tableReference);
}
checkSchemaChanges(tableContainer.table.getSchema().getFields(), tableSchema.getFields());
tableContainer.table.setSchema(tableSchema);
for (Stream stream : writeStreams.values()) {
if (stream.tableContainer == tableContainer) {
stream.setUpdatedSchema(tableSchema);
}
}
}
}
@FormatMethod
void checkSchemaPredicate(boolean predicate, String msgFormat, Object... args)
throws IOException {
String msg = String.format(msgFormat, args);
if (!predicate) {
throw new GoogleJsonResponseException(
new HttpResponseException.Builder(
HttpStatusCodes.STATUS_CODE_PRECONDITION_FAILED, msg, new HttpHeaders()),
null);
}
}
private void checkSchemaChanges(
List<TableFieldSchema> oldSchema, List<TableFieldSchema> newSchema) throws IOException {
List<com.google.cloud.bigquery.storage.v1.TableFieldSchema> oldSchemaProtos =
oldSchema.stream()
.map(TableRowToStorageApiProto::tableFieldToProtoTableField)
.collect(Collectors.toList());
List<com.google.cloud.bigquery.storage.v1.TableFieldSchema> newSchemaProtos =
newSchema.stream()
.map(TableRowToStorageApiProto::tableFieldToProtoTableField)
.collect(Collectors.toList());
checkSchemaChangesProtos(oldSchemaProtos, newSchemaProtos);View on GitHub (pinned to 12126d8942)