{"record":{"id":"4d7db152573eb71b","repo":"apache/beam","slug":"null-values-are-not-supported","errorCode":null,"errorMessage":"Null values are not supported","messagePattern":"Null 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":361,"sourceCode":"      SCHEMA_REGISTRY.registerSchemaProvider(value.getClass(), new JavaFieldSchema());\n      try {\n        toRowFunc =\n            (SerializableFunction<Object, Row>) SCHEMA_REGISTRY.getToRowFunction(value.getClass());\n      } catch (NoSuchSchemaException e1) {\n        throw new RuntimeException(e1);\n      }\n    }\n    return toRowFunc.apply(value);\n  }\n\n  private Object[] convertComplexTypesToRows(@Nullable Object @NonNull [] values) {\n    Object[] converted = new Object[values.length];\n    for (int i = 0; i < values.length; i++) {\n      Object value = values[i];\n      if (value != null) {\n        converted[i] = isCustomType(value.getClass()) ? convertCustomValue(value) : value;\n      } else {\n        throw new RuntimeException(\"Null values are not supported\");\n      }\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) {","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/python/src/main/java/org/apache/beam/sdk/extensions/python/PythonExternalTransform.java#L343-L379","documentation":"convertComplexTypesToRows converts Java kwargs values into Beam Rows for the Python expansion service. Null entries cannot be represented in this conversion, so the library throws RuntimeException when any element of the values array is null. Every kwarg passed via withKwarg/kwargs must be non-null and convertible.","triggerScenarios":"Passing a null value as an argument via withKwarg/withArgs (e.g. withKwarg(\"name\", null)) or building kwargs from a map/nullable variables that contain nulls; convertComplexTypesToRows is invoked from buildOrGetKwargsRow/convertedValues during payload generation.","commonSituations":"Optional Java parameters left null and forwarded straight into kwargs; configuration objects with absent fields passed as-is; ternary expressions like config.get(\"x\") returning null.","solutions":["Replace null kwargs with an explicit non-null sentinel or default value","Skip the withKwarg call entirely when the value is null so the Python default is used","Wrap nullable values (e.g. Optional.ofNullable(...).orElse(default)) before passing"],"exampleFix":"// before\ntransform.withKwarg(\"limit\", maybeLimit); // NPE when null\n// after\nif (maybeLimit != null) {\n  transform.withKwarg(\"limit\", maybeLimit);\n}","handlingStrategy":"validation","validationCode":"if (value == null) {\n  throw new IllegalArgumentException(\"kwarg '\" + name + \"' must be non-null\");\n}\ntransform.withKwarg(name, value);","typeGuard":"boolean isUsableKwarg(Object v) { return v != null; }","tryCatchPattern":"try {\n  transform.withKwarg(name, value);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"Null values are not supported\")) {\n    // supply a default or drop the kwarg\n  }\n}","preventionTips":["Never pass null kwarg/arg values; skip the withKwarg call instead","Use Optional or explicit defaults when converting config to kwargs","Sanitize maps of kwargs for null entries before applying"],"tags":["java","beam","null-value","kwargs","cross-language"],"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"}