apache/beam · error · RuntimeException
null driver given by driver provider
Error message
null driver given by driver provider
What it means
ReadFn/WriteUnwindFn's createDriver() invokes the user-supplied driverProviderFn and checks that a non-null org.neo4j.driver.Driver comes back. The provider returned null (Driver is an interface, so the type system cannot catch this), so the DoFn cannot connect to Neo4j and fails at setup/use time.
Solutions
- Make the driver provider always return a real Driver: build it with GraphDatabase.driver(uri, AuthTokens.basic(user, password)).
- Throw a descriptive exception inside the provider when configuration is missing instead of returning null.
- Log/validate connection parameters before the pipeline runs so the provider never hits the null path.
Example fix
// before
.withDriverProviderFn(config -> config.isComplete() ? null : buildDriver(config))
// after
.withDriverProviderFn(config -> {
if (!config.isComplete()) { throw new IllegalArgumentException("Incomplete Neo4j config"); }
return GraphDatabase.driver(config.getUri(), AuthTokens.basic(config.getUser(), config.getPassword()));
}) Defensive patterns
Strategy: validation
Validate before calling
Driver d = driverProviderFn.apply(null); if (d == null) throw new IllegalStateException("driver provider must return a Driver"); Prevention
- Never return null from driverProviderFn; throw on missing config instead.
- Smoke-test the provider locally with a try (Session s = driver.session()) before running the pipeline.
- Avoid mocks returning null in integration tests.
When it happens
Trigger: A driverProviderFn lambda or SerializableFunction that returns null — e.g. a factory that short-circuits on bad config, memoized supplier that failed silently, or code path returning null instead of throwing.
Common situations: Config-driven driver factories that return null when URL/credentials are missing; test doubles (mocks) returning null; swallowing exceptions inside the provider and falling through with a null return.
Related errors
- Error mapping Neo4J result
- Error writing " + unwindList.size() + " rows to Neo4j with…
- neo4j session was not initialized correctly
- please provide a parameters function
- please provide a row mapper
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/286b7f3241ba803d.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/neo4j/src/main/java/org/apache/beam/sdk/io/neo4j/Neo4jIO.java:706
@NonNull SerializableFunction<Void, Driver> driverProviderFn,
@NonNull SessionConfig sessionConfig,
@NonNull TransactionConfig transactionConfig) {
this.driverProviderFn = driverProviderFn;
this.sessionConfig = sessionConfig;
this.transactionConfig = transactionConfig;
this.driverSession = DriverSession.emptyClosed();
}
/**
* Delay the creation of driver and session until we actually have data to do something with.
*/
@Setup
public void setup() {}
protected @NonNull Driver createDriver() {
Driver driver = driverProviderFn.apply(null);
if (driver == null) {
throw new RuntimeException("null driver given by driver provider");
}
return driver;
}
protected @Initialized @NonNull DriverSession buildDriverSession() {
@NonNull Driver driver = createDriver();
@NonNull Session session = driver.session(sessionConfig);
return new DriverSession(driver, session);
}
@StartBundle
public void startBundle() {
if (driverSession == null || driverSession.closed.get()) {
driverSession = buildDriverSession();
}
}
@FinishBundleView on GitHub (pinned to 12126d8942)