{"record":{"id":"542e50dd18c412a1","repo":"quarkusio/quarkus","slug":"the-provider-class-name-cannot-be-null-or-blank","errorCode":null,"errorMessage":"The provider class name cannot be null or blank","messagePattern":"The provider class name cannot be null or blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ServiceProviderBuildItem.java","lineNumber":193,"sourceCode":"     * An internal overload that must be called with an immutable {@link List} of {@code providers}\n     *\n     * @param serviceInterfaceClassName the interface whose service interface descriptor file we want to embed\n     * @param providers the list of provider class names that must already be mentioned in the file\n     * @param marker just a way to differentiate this constructor from {@link #ServiceProviderBuildItem(String, List)};\n     *        the value is ignored\n     */\n    private ServiceProviderBuildItem(String serviceInterfaceClassName, List<String> providers, boolean marker) {\n        this.serviceInterface = Objects.requireNonNull(serviceInterfaceClassName, \"The service interface must not be `null`\");\n        this.providers = providers;\n\n        // Validation\n        if (serviceInterface.isEmpty()) {\n            throw new IllegalArgumentException(\"The serviceDescriptorFile interface cannot be blank\");\n        }\n\n        providers.forEach(s -> {\n            if (s == null || s.isEmpty()) {\n                throw new IllegalArgumentException(\"The provider class name cannot be null or blank\");\n            }\n        });\n    }\n\n    /**\n     * @return an immutable {@link List} of provider class names\n     */\n    public List<String> providers() {\n        return providers;\n    }\n\n    /**\n     * @return the resource path for the service descriptor file\n     */\n    public String serviceDescriptorFile() {\n        return SPI_ROOT + serviceInterface;\n    }\n}","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ServiceProviderBuildItem.java#L175-L211","documentation":"The constructor also validates every entry of the providers list: any null or empty provider class name triggers this IllegalArgumentException, ensuring the generated native-image service registration contains only valid class names.","triggerScenarios":"Creating a ServiceProviderBuildItem whose providers List contains null or \"\" elements, e.g. from parsing descriptor lines without filtering empties.","commonSituations":"Splitting a descriptor file on newlines and passing blank trailing lines; collecting class names from config that has empty entries.","solutions":["Filter null/blank entries before constructing: providers.stream().filter(s -> s != null && !s.isBlank())","Use ServiceProviderBuildItem.allProviders/allProvidersFromClassPath which parse cleanly","Fix the source (config or file parsing) producing empty names"],"exampleFix":"// before\nnew ServiceProviderBuildItem(spi, rawProviders);\n// after\nList<String> clean = rawProviders.stream().filter(Objects::nonNull).filter(s -> !s.isBlank()).toList();\nnew ServiceProviderBuildItem(spi, clean);","handlingStrategy":"validation","validationCode":"List<String> clean = providers.stream().filter(Objects::nonNull).filter(s -> !s.isEmpty()).toList();\nif (clean.isEmpty()) throw new IllegalStateException(\"no providers\");","typeGuard":"boolean hasValidProviders(List<String> l) { return l != null && l.stream().allMatch(s -> s != null && !s.isEmpty()); }","tryCatchPattern":null,"preventionTips":["Filter blank lines when parsing descriptor files","Reject empty config entries before building the list","Prefer allProviders()/allProvidersFromClassPath() over manual construction"],"tags":["native-image","spi","validation"],"backgroundTag":"invalid-argument-null-or-blank","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}