apache/beam · error · java.lang.RuntimeException

Could not decode the value from Row

Error message

Could not decode the value from Row 

What it means

Fallback branch of getDecodedValueFromRow: if the expected type is not primitive/wrapper/String, not an array, not a List, and the supplied value is not a Row, there is no decoding strategy and it throws RuntimeException including the offending value.

Source

Thrown at sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java:369

              (Class<?>) ((ParameterizedType) genericType).getActualTypeArguments()[0];
          decodedList.add(getDecodedValueFromRow(elementType, obj, null));
        } else {
          throw new RuntimeException("Could not determine the generic type of the list");
        }
      }
      return decodedList;
    } else if (valueFromRow instanceof Row) {
      Row row = (Row) valueFromRow;
      SerializableFunction<Row, ?> fromRowFunc;
      try {
        fromRowFunc = SCHEMA_REGISTRY.getFromRowFunction(type);
      } catch (NoSuchSchemaException e) {
        throw new IllegalArgumentException(
            "Could not determine the row function for class " + type, e);
      }
      return fromRowFunc.apply(row);
    }
    throw new RuntimeException("Could not decode the value from Row " + valueFromRow);
  }

  @SuppressWarnings("argument")
  private Object[] getParameterValues(
      java.lang.reflect.Parameter[] parameters, Row constrtuctorRow, Type[] genericTypes) {
    ArrayList<Object> parameterValues = new ArrayList<>();
    for (int i = 0; i < parameters.length; ++i) {
      java.lang.reflect.Parameter parameter = parameters[i];
      Class<?> parameterClass = parameter.getType();
      Object parameterValue =
          getDecodedValueFromRow(parameterClass, constrtuctorRow.getValue(i), genericTypes[i]);
      parameterValues.add(parameterValue);
    }

    return parameterValues.toArray();
  }

  @SuppressWarnings("argument")

View on GitHub (pinned to 12126d8942)

Solutions

  1. Align the constructor schema field types with the Java constructor parameter types so the right branch executes.
  2. If the value should be a complex object, ensure it is sent as a Row and the class is schema-registered (see NoSuchSchema error).
  3. Extend decode handling (or convert the payload) for types like Map/bytes if genuinely needed.
  4. Catch RuntimeException at parameterValue/constructor level and reject the expansion request with a clear message.

Example fix

// before: scalar supplied for schema-typed parameter
Row.ofSchema(schema, Arrays.asList("just-a-string")) // param is MyConfig
// after: supply a Row for the nested type
Row.ofSchema(schema, Arrays.asList(Row.withSchema(configSchema).addValue("n").build()))
Defensive patterns

Strategy: validation

Validate before calling

// pre-check that each Row value kind matches the declared field type
Schema.Field.Type ft = schema.getField(i).getType(); assert (ft.getTypeName().isPrimitiveType()) == isScalar(rowValue(i));

Try / catch

try { decodeValue(...); } catch (RuntimeException e) { if (e.getMessage().startsWith("Could not decode the value from Row")) { /* reject payload with type guidance */ } throw e; }

Prevention

When it happens

Trigger: Constructor parameter expects a complex type (e.g. a schema class) but the Row cell contains a scalar, or vice versa the type dispatch falls through — e.g. byte[] vs List handling, or value null/Map types not covered by the if/else chain.

Common situations: Mismatched constructor schema field types vs Java parameter types; custom types that are neither schema-registered nor Row-encoded; SDKs encoding values in formats the Java expansion service does not understand.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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