apache/beam · error · java.lang.IllegalArgumentException

%s is not nullable in field %s

Error message

%s is not nullable in  field %s

What it means

While matching/capturing a Row's field values, the resulting processed value was null but the field's Schema.FieldType is declared non-nullable. Beam Rows enforce nullability declared in the schema, so a null appearing where the schema forbids it is rejected with IllegalArgumentException.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/values/RowUtils.java:214

          break;
        case DOUBLE:
          processedValue = cases.processDouble(rowPosition, (Double) value, this);
          break;
        case STRING:
          processedValue = cases.processString(rowPosition, (String) value, this);
          break;
        case BOOLEAN:
          processedValue = cases.processBoolean(rowPosition, (Boolean) value, this);
          break;
        default:
          // Shouldn't actually get here, but we need this case to satisfy linters.
          throw new IllegalArgumentException(
              String.format(
                  "Not a primitive type for field name %s: %s", rowPosition.descriptor, fieldType));
      }
      if (processedValue == null) {
        if (!fieldType.getNullable()) {
          throw new IllegalArgumentException(
              String.format("%s is not nullable in  field %s", fieldType, rowPosition.descriptor));
        }
      }
      return processedValue;
    }
  }

  static class FieldOverride {
    FieldOverride(Object overrideValue) {
      this.overrideValue = overrideValue;
    }

    Object getOverrideValue() {
      return overrideValue;
    }

    final Object overrideValue;
  }

View on GitHub (pinned to 12126d8942)

Solutions

  1. Declare the field nullable: Schema.FieldType.<type>().withNullable(true), or annotate/allow null in the POJO
  2. Fix the upstream data so the field is never null (provide defaults before row creation)
  3. Validate/clean records before Row creation, replacing nulls with sentinel/default values

Example fix

// before
Schema.Field.of("name", Schema.FieldType.STRING)
// after (data can contain null)
Schema.Field.of("name", Schema.FieldType.STRING.withNullable(true))
Defensive patterns

Strategy: validation

Validate before calling

if (value == null && !fieldType.getNullable()) {
  value = defaultValue; // or make field nullable
}

Try / catch

try { row = Row.withSchema(schema).addValues(...).build(); } catch (IllegalArgumentException e) { log.error("schema nullability violation", e); throw e; }

Prevention

When it happens

Trigger: RowUtils.match (via processRow/capturedElement/processMap) encounters null for a field whose FieldType.getNullable() is false — e.g. attaching a schema to values containing null, or a getter returning null for a non-nullable field.

Common situations: Declaring fields non-nullable in @DefaultSchema POJOs but leaving the Java field null; pipeline data with missing values fed into Row-based sources; schema evolved to non-nullable while old data still has nulls.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/f90db14a56b49367. Report an issue: GitHub.