apache/beam · error

Schema with id has encoding_positions_set=True, but not all…

Error message

Schema with id ${this.schema.id} has encoding_positions_set=True, but not all fields have encoding_position set

What it means

RowCoder's constructor validated a schema that declares encodingPositionsSet=true, meaning fields carry explicit encoding_position metadata, yet some fields lack an encodingPosition entry. The schema (id in the message) is the faulty input: it is internally inconsistent between its flag and per-field positions.

Solutions

  1. Fix the producer of the schema so every field's encoding_position is set whenever the schema-level encoding_positions_set flag is true.
  2. If positions are just 0..n-1, clear the encodingPositionsSet flag and let RowCoder assign trivial positions.
  3. Regenerate/re-serialize the schema and confirm all fields round-trip with their positions intact.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sdks/typescript/src/apache_beam/coders/row_coder.ts:344 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/29c13caadd46a9c5. Report an issue: GitHub.

Appendix: source

Thrown at sdks/typescript/src/apache_beam/coders/row_coder.ts:344

    return new RowCoder(RowCoder.inferSchemaOfJSON(obj));
  }

  constructor(rawSchema: Schema | Uint8Array) {
    const schema: Schema =
      rawSchema instanceof Uint8Array
        ? Schema.fromBinary(rawSchema as Uint8Array)
        : (rawSchema as Schema);
    this.schema = schema as Schema;
    this.nFields = this.schema.fields.length;
    this.fieldNames = this.schema.fields.map((f: Field) => f.name);
    this.fieldNullable = this.schema.fields.map((f: Field) => f.type?.nullable);
    this.encodingPositions = this.schema.fields.map((_, i) => i);

    if (this.schema.encodingPositionsSet) {
      // Should never be duplicate encoding positions.
      let encPosx = schema.fields.map((f: Field) => f.encodingPosition);
      if (encPosx.length !== this.encodingPositions.length) {
        throw new Error(
          `Schema with id ${this.schema.id} has encoding_positions_set=True, but not all fields have encoding_position set`,
        );
      }
      // Checking if positions are in {0, ..., length-1}
      this.encodingPositionsAreTrivial = encPosx === this.encodingPositions;
      this.encodingPositions = encPosx;
      this.encodingPositionsArgsSorted = argsort(encPosx);
    }

    this.hasNullableFields = this.schema.fields.some(
      (f: Field) => f.type?.nullable,
    );
    this.components = this.encodingPositions
      .map((i) => this.schema.fields[i])
      .map((f: Field) => {
        if (f.type !== undefined) {
          return this.getNonNullCoderFromType(f.type);
        }

View on GitHub (pinned to 12126d8942)