quarkusio/quarkus · error · IllegalStateException
name cannot be null
Error message
name cannot be null
What it means
DevServicesResultBuildItem.Builder.build() validates that a service name was set before constructing the result. The name identifies which dev service produced the result and must be non-null. Throwing IllegalStateException here signals the builder was used without calling the mandatory name setter.
Source
Thrown at core/deployment/src/main/java/io/quarkus/deployment/builditem/DevServicesResultBuildItem.java:300
public DiscoveredServiceBuilder containerId(String containerId) {
this.containerId = containerId;
return this;
}
public DiscoveredServiceBuilder config(Map<String, String> config) {
this.config = config;
return this;
}
public DiscoveredServiceBuilder description(String description) {
this.description = description;
return this;
}
public DevServicesResultBuildItem build() {
if (name == null) {
throw new IllegalStateException("name cannot be null");
}
return new DevServicesResultBuildItem(name, description, containerId, config);
}
}
public static class OwnedServiceBuilder<T extends Startable> {
private String name;
private String description;
private Map<String, String> config;
private String serviceName;
private Object serviceConfig;
private Supplier<? extends Startable> startableSupplier;
private Consumer<? extends Startable> postStartAction;
private Map<String, Function<Startable, String>> applicationConfigProvider;
private Set<String> highPriorityConfig;
private final Set<DevServiceConfigDependency<? extends Startable>> dependencies = new HashSet<>();
private final Set<DevServiceConfigDependency<? extends Startable>> optionalDependencies = new HashSet<>();
View on GitHub (pinned to e1c734241f)
Solutions
- Call the builder's name-setting method (e.g. .name("my-service")) before .build().
- Ensure the name matches the service identifier used in the DevServicesRequest/feature priority so the result is attributed correctly.
- Add a unit test asserting the built item has the expected name to catch regressions.
Example fix
// before
return new DevServicesResultBuildItem.Builder()
.description("Postgres dev service")
.config(Map.of("quarkus.datasource.jdbc.url", url))
.build();
// after
return new DevServicesResultBuildItem.Builder()
.name("postgres")
.description("Postgres dev service")
.config(Map.of("quarkus.datasource.jdbc.url", url))
.build(); Defensive patterns
Strategy: validation
Validate before calling
if (builderName == null || builderName.isBlank()) {
throw new IllegalStateException("DevServicesResultBuildItem name must be set before build()");
} Try / catch
try {
DevServicesResultBuildItem result = builder.build();
} catch (IllegalStateException e) {
if ("name cannot be null".equals(e.getMessage())) {
// set the service name and rebuild
}
throw e;
} Prevention
- Make the service name the first builder call, right after creating the Builder
- Use a constant for the dev service name shared with the DevServicesRequest
- Cover the builder with a small unit test asserting name(), config(), and containerId()
When it happens
Trigger: Building a DevServicesResultBuildItem via its builder without calling the method that sets name (e.g. new DevServicesResultBuildItem.Builder() ... .build() with name never assigned).
Common situations: Extension authors writing custom dev service support who construct the result at the end of a startSuppliers method and forget the name; refactoring that renames/removes the name-setting call.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- One of either visitorFunction or inputTransformer must be se
- Dev services for ${request.getName()} requires a startable s
- Either location or predicate must be set
- Predicate already set
- Location already set
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/7870b05492d023e7.
Report an issue: GitHub.