apache/beam · error
Attempted to encode null for non-nullable field \
Error message
Attempted to encode null for non-nullable field \"${this.schema.fields[i].name}\". What it means
During encode, the row value supplied for the named field was null or undefined while the schema declares that field non-nullable, and the null-bitmask machinery refuses to encode it. The faulty inputs are the element being encoded and the specific field named in the message.
Solutions
- Mark the field nullable in the schema (Field with nullable=true) if null is a legitimate value.
- Fix the upstream DoFn so it never emits null/undefined for the named non-nullable field.
- If null means 'absent', restructure the row to omit the field or use a sentinel value consistent with the schema.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at sdks/typescript/src/apache_beam/coders/row_coder.ts:411 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/6b74d3322c1f1689.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/typescript/src/apache_beam/coders/row_coder.ts:411
}
running |= (attr === null || attr === undefined ? 1 : 0) << i % 8;
});
nullFields.push(running);
}
}
writer.bytes(new Uint8Array(nullFields));
// An encoding for each non-null field, concatenated together.
let positions = this.encodingPositionsAreTrivial
? this.encodingPositions
: this.encodingPositionsArgsSorted;
positions.forEach((i) => {
let attr = attrs[i];
if (attr === null || attr === undefined) {
if (!this.fieldNullable[i]) {
throw new Error(
`Attempted to encode null for non-nullable field \"${this.schema.fields[i].name}\".`,
);
}
} else {
this.components[i].encode(attr, writer, Context.needsDelimiters);
}
});
}
decode(reader: Reader, context: Context): any {
let nFields = reader.int32();
// Addressing Null values
let nulls: any[],
hasNulls = false,
nullMaskBytes = reader.int32(),
nullMask = reader.buf.slice(reader.pos, reader.pos + nullMaskBytes);
View on GitHub (pinned to 12126d8942)