{"record":{"id":"7870b05492d023e7","repo":"quarkusio/quarkus","slug":"name-cannot-be-null","errorCode":null,"errorMessage":"name cannot be null","messagePattern":"name cannot be null","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/builditem/DevServicesResultBuildItem.java","lineNumber":300,"sourceCode":"\n        public DiscoveredServiceBuilder containerId(String containerId) {\n            this.containerId = containerId;\n            return this;\n        }\n\n        public DiscoveredServiceBuilder config(Map<String, String> config) {\n            this.config = config;\n            return this;\n        }\n\n        public DiscoveredServiceBuilder description(String description) {\n            this.description = description;\n            return this;\n        }\n\n        public DevServicesResultBuildItem build() {\n            if (name == null) {\n                throw new IllegalStateException(\"name cannot be null\");\n            }\n            return new DevServicesResultBuildItem(name, description, containerId, config);\n        }\n    }\n\n    public static class OwnedServiceBuilder<T extends Startable> {\n        private String name;\n        private String description;\n        private Map<String, String> config;\n        private String serviceName;\n        private Object serviceConfig;\n        private Supplier<? extends Startable> startableSupplier;\n        private Consumer<? extends Startable> postStartAction;\n        private Map<String, Function<Startable, String>> applicationConfigProvider;\n        private Set<String> highPriorityConfig;\n        private final Set<DevServiceConfigDependency<? extends Startable>> dependencies = new HashSet<>();\n        private final Set<DevServiceConfigDependency<? extends Startable>> optionalDependencies = new HashSet<>();\n","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/builditem/DevServicesResultBuildItem.java#L282-L318","documentation":"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.","triggerScenarios":"Building a DevServicesResultBuildItem via its builder without calling the method that sets name (e.g. new DevServicesResultBuildItem.Builder() ... .build() with name never assigned).","commonSituations":"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.","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."],"exampleFix":"// before\nreturn new DevServicesResultBuildItem.Builder()\n        .description(\"Postgres dev service\")\n        .config(Map.of(\"quarkus.datasource.jdbc.url\", url))\n        .build();\n// after\nreturn new DevServicesResultBuildItem.Builder()\n        .name(\"postgres\")\n        .description(\"Postgres dev service\")\n        .config(Map.of(\"quarkus.datasource.jdbc.url\", url))\n        .build();","handlingStrategy":"validation","validationCode":"if (builderName == null || builderName.isBlank()) {\n    throw new IllegalStateException(\"DevServicesResultBuildItem name must be set before build()\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    DevServicesResultBuildItem result = builder.build();\n} catch (IllegalStateException e) {\n    if (\"name cannot be null\".equals(e.getMessage())) {\n        // set the service name and rebuild\n    }\n    throw e;\n}","preventionTips":["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()"],"tags":["quarkus","dev-services","builder","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}