{"record":{"id":"4a3a28fd31c75558","repo":"quarkusio/quarkus","slug":"service-interface-name-cannot-be-null-or-blank","errorCode":null,"errorMessage":"service interface name cannot be null or blank","messagePattern":"service interface 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":46,"sourceCode":"    private static final PathFilter SPI_FILTER = PathFilter.forIncludes(List.of(SPI_ROOT + \"*\"));\n\n    private final String serviceInterface;\n    private final List<String> providers;\n\n    /**\n     * Creates and returns a {@link ServiceProviderBuildItem} for the {@code serviceInterfaceClassName} by including\n     * all the providers that are listed in the service interface descriptor file.\n     *\n     * @param serviceInterfaceClassName the interface whose service interface descriptor file we want to embed\n     * @param serviceInterfaceDescriptorFile the path to the service interface descriptor file\n     * @return\n     * @throws IOException\n     */\n    public static ServiceProviderBuildItem allProviders(final String serviceInterfaceClassName,\n            final Path serviceInterfaceDescriptorFile)\n            throws IOException {\n        if (serviceInterfaceClassName == null || serviceInterfaceClassName.trim().isEmpty()) {\n            throw new IllegalArgumentException(\"service interface name cannot be null or blank\");\n        }\n        if (serviceInterfaceDescriptorFile == null) {\n            throw new IllegalArgumentException(\"service interface descriptor file path cannot be null\");\n        }\n        final Set<String> classNames = new LinkedHashSet<>();\n        final List<String> lines = Files.readAllLines(serviceInterfaceDescriptorFile, StandardCharsets.UTF_8);\n        // parse each line and add each listed provider\n        for (String line : lines) {\n            final int commentIndex = line.indexOf('#');\n            if (commentIndex >= 0) {\n                // strip off anything after the # (including the #)\n                line = line.substring(0, commentIndex);\n            }\n            line = line.trim();\n            if (!line.isEmpty()) {\n                classNames.add(line);\n            }\n        }","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ServiceProviderBuildItem.java#L28-L64","documentation":"ServiceProviderBuildItem.allProviders() registers all providers from a service descriptor file for native image inclusion. It validates the service interface class name is non-null and non-blank before reading the descriptor, throwing IllegalArgumentException otherwise.","triggerScenarios":"Calling ServiceProviderBuildItem.allProviders(null, path) or allProviders(\"  \", path) from a build step.","commonSituations":"Dynamically computed service interface name resolves to null (missing class metadata) or an empty string after trimming; misconfigured build-step parameters.","solutions":["Pass the fully-qualified service interface name (e.g. \"com.example.MySpi\")","Verify the constant/variable supplying the name is populated before calling","Add a null/blank check with a clear failure at the call site"],"exampleFix":"// before\nServiceProviderBuildItem.allProviders(spiName, descriptorPath);\n// after\nObjects.requireNonNull(spiName, \"spiName required\");\nif (spiName.isBlank()) throw new IllegalStateException(\"spi not configured\");\nServiceProviderBuildItem.allProviders(spiName, descriptorPath);","handlingStrategy":"validation","validationCode":"if (serviceInterfaceClassName == null || serviceInterfaceClassName.trim().isEmpty()) throw new IllegalStateException(\"SPI interface name required\");","typeGuard":"boolean isValidClassName(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try { item = ServiceProviderBuildItem.allProviders(name, path); } catch (IllegalArgumentException e) { log.error(\"Invalid SPI name\", e); throw e; }","preventionTips":["Always pass hardcoded or verified fully-qualified interface names","Validate computed names before calling factory methods","Keep SPI names in constants rather than dynamic strings"],"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"}