{"record":{"id":"07fe2bef859c6657","repo":"apache/beam","slug":"null-field-values-are-not-supported","errorCode":null,"errorMessage":"Null field values are not supported","messagePattern":"Null field values are not supported","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/python/src/main/java/org/apache/beam/sdk/extensions/python/PythonExternalTransform.java","lineNumber":380,"sourceCode":"      }\n    }\n    return converted;\n  }\n\n  @VisibleForTesting\n  Row buildOrGetArgsRow() {\n    Schema schema = generateSchemaFromFieldValues(argsArray, null);\n    Object[] convertedValues = convertComplexTypesToRows(argsArray);\n    return Row.withSchema(schema).addValues(convertedValues).build();\n  }\n\n  private Schema generateSchemaDirectly(\n      @Nullable Object @NonNull [] fieldValues, @NonNull String @Nullable [] fieldNames) {\n    Schema.Builder builder = Schema.builder();\n    int counter = 0;\n    for (Object field : fieldValues) {\n      if (field == null) {\n        throw new RuntimeException(\"Null field values are not supported\");\n      }\n      String fieldName = (fieldNames != null) ? fieldNames[counter] : \"field\" + counter;\n      if (field instanceof Row) {\n        // Rows are used as is but other types are converted to proper field types.\n        builder.addRowField(fieldName, ((Row) field).getSchema());\n      } else if (typeHints.containsKey(field.getClass())) {\n        builder.addField(fieldName, typeHints.get(field.getClass()));\n      } else {\n        builder.addField(\n            fieldName,\n            StaticSchemaInference.fieldFromType(\n                TypeDescriptor.of(field.getClass()),\n                JavaFieldSchema.JavaFieldTypeSupplier.INSTANCE));\n      }\n\n      counter++;\n    }\n","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/python/src/main/java/org/apache/beam/sdk/extensions/python/PythonExternalTransform.java#L362-L398","documentation":"generateSchemaDirectly builds a Beam Schema from a row of field values so kwargs can be serialized for Python expansion. Since the field type of each value must be inferred from the value itself, a null field value makes type inference impossible and the library throws RuntimeException. All field values used to generate the schema must be non-null.","triggerScenarios":"Passing null in the varargs of withKwargs/args when no explicit type hints cover the value; generateSchemaFromFieldValues calls generateSchemaDirectly with an array containing nulls.","commonSituations":"Null optional parameters forwarded into kwargs; collections containing null elements passed as a single argument; uninitialized fields of a config bean used as kwargs.","solutions":["Ensure all argument values are non-null, providing defaults where needed","Register an explicit withTypeHint(Class, Schema.FieldType) for the affected type and pass a non-null value","Filter out null entries before building the kwargs"],"exampleFix":"// before\ntransform.withArgs(values); // values may contain nulls\n// after\ntransform.withArgs(Arrays.stream(values).map(v -> v != null ? v : DEFAULT).toArray());","handlingStrategy":"validation","validationCode":"for (Object v : fieldValues) {\n  if (v == null) throw new IllegalArgumentException(\"schema fields must be non-null\");\n}\ntransform.withKwargs(...);","typeGuard":"boolean hasNoNulls(Object[] vals) {\n  return java.util.Arrays.stream(vals).allMatch(java.util.Objects::nonNull);\n}","tryCatchPattern":"try {\n  transform.withArgs(fieldValues);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"Null field values\")) {\n    // add withTypeHint for the affected type or default the value\n  }\n}","preventionTips":["Provide explicit withTypeHint for types that may arrive null-wrapped or custom","Replace null fields with typed defaults before building kwargs","Assert argument arrays are null-free in tests"],"tags":["java","beam","null-value","schema","kwargs"],"backgroundTag":"null-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}