apache/flink · error · FlinkRuntimeException
A user-provided generator function threw an exception on thi
Error message
A user-provided generator function threw an exception on this input: %s
What it means
Thrown by convert() in DoubleEmittingSourceReaderWithCheckpointsInBetween when generatorFunction.map(value) throws any exception. The message uses String.format to include the toString() of the specific input value that caused the failure, and the original exception is wrapped in FlinkRuntimeException.
Source
Thrown at flink-connectors/flink-connector-datagen/src/main/java/org/apache/flink/connector/datagen/source/DoubleEmittingSourceReaderWithCheckpointsInBetween.java:155
}
if (allowedToExit != null) {
if (allowedToExit.getAsBoolean()) {
availability.complete(null);
}
}
}
@Override
protected O convert(E value) {
try {
return generatorFunction.map(value);
} catch (Exception e) {
String message =
String.format(
"A user-provided generator function threw an exception on this input: %s",
value.toString());
throw new FlinkRuntimeException(message, e);
}
}
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Inspect the input value in the error message to identify the problematic data.
- Add input validation and null-checks in the GeneratorFunction.map() method.
- Add try-catch in map() for known edge cases, returning a default or filtered value.
- Fix the root cause in the mapping logic for the failing input.
Example fix
// before: map() throws NPE on null field
GeneratorFunction<Long, String> fn = index -> records.get(index).getName().toUpperCase();
// after: guard against null
GeneratorFunction<Long, String> fn = index -> {
String name = records.get(index).getName();
return name != null ? name.toUpperCase() : "UNKNOWN";
}; Defensive patterns
Strategy: try-catch
Validate before calling
// Validate map() handles all known inputs before using the source
GeneratorFunction<E, O> fn = ...;
for (E testInput : testInputs) {
fn.map(testInput); // should not throw for valid inputs
} Try / catch
try {
sourceReader.pollNext(output);
} catch (FlinkRuntimeException e) {
if (e.getMessage().startsWith("A user-provided generator function threw")) {
// extract the failing input value from the message, fix the map() logic
}
throw e;
} Prevention
- Add null-checks and input validation in GeneratorFunction.map().
- Unit-test map() with edge-case inputs (null fields, empty strings, boundary values).
- Handle known exceptions inside map() with defaults or filtering.
When it happens
Trigger: The user-provided GeneratorFunction's map() method throws on a specific input value. Causes include NPE, arithmetic errors, business logic exceptions, class cast failures, or unhandled edge cases in the mapping logic.
Common situations: Generator function that does not handle null fields in the input; index out of bounds in a lookup function; type cast failure; division by zero or other arithmetic error on specific input.
Related errors
- A user-provided generator function threw an exception on thi
- Failed to open the GeneratorFunction
- Failed to open the GeneratorFunction
- SplitFetcher thread %d received unexpected exception while p
- One or more fetchers have encountered exception
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/dead7798fb38dd2d.
Report an issue: GitHub.