{"record":{"id":"dea22e5660d2d48d","repo":"quarkusio/quarkus","slug":"the-tls-configuration-to-register-cannot-be-null","errorCode":null,"errorMessage":"The TLS configuration to register cannot be null","messagePattern":"The TLS configuration to register cannot be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/CertificateRecorder.java","lineNumber":225,"sourceCode":"    public Optional<TlsConfiguration> getDefault() {\n        return get(TlsConfig.DEFAULT_NAME);\n    }\n\n    @Override\n    public void register(String name, TlsConfiguration configuration) {\n        if (name == null) {\n            throw new IllegalArgumentException(\"The name of the TLS configuration to register cannot be null\");\n        }\n        if (name.equals(TlsConfig.DEFAULT_NAME)) {\n            throw new IllegalArgumentException(\"The name of the TLS configuration to register cannot be <default>\");\n        }\n        if (name.equals(TlsConfig.JAVA_NET_SSL_TLS_CONFIGURATION_NAME)) {\n            throw new IllegalArgumentException(\n                    \"The TLS configuration name \" + TlsConfig.JAVA_NET_SSL_TLS_CONFIGURATION_NAME\n                            + \" is reserved for providing access to default SunJSSE keystore; neither Quarkus extensions nor end users can adjust of override it\");\n        }\n        if (configuration == null) {\n            throw new IllegalArgumentException(\"The TLS configuration to register cannot be null\");\n        }\n        certificates.put(name, configuration);\n    }\n\n    public Supplier<TlsConfigurationRegistry> getSupplier() {\n        return new Supplier<TlsConfigurationRegistry>() {\n            @Override\n            public TlsConfigurationRegistry get() {\n                return CertificateRecorder.this;\n            }\n        };\n    }\n\n    public void register(String name, Supplier<TlsConfiguration> supplier) {\n        register(name, supplier.get());\n    }\n\n    static <T> InstanceHandle<T> lookupProvider(Class<T> type, String bucketName) {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/CertificateRecorder.java#L207-L243","documentation":"CertificateRecorder.register requires a non-null TlsConfiguration object to store in the registry. A null configuration would leave a registered name with no backing keystore/truststore, so it throws IllegalArgumentException before mutating the registry.","triggerScenarios":"Invoking register(name, configuration) where the TlsConfiguration argument is null — e.g. a conditional build step produced no configuration, or a supplier/option returned null.","commonSituations":"Custom extension recorders passing an optional/defaulted configuration that is absent; reflection or SPI-based construction returning null; code refactoring where a config mapping option was removed and now yields null.","solutions":["Ensure a valid TlsConfiguration is constructed before calling register; check configuration != null at the call site.","If the configuration is genuinely absent, skip the register call instead of registering null.","If the null comes from missing config properties, define the keystore/truststore options (quarkus.tls.*.key-store etc.) or provide a TlsCertificateScanner/provider bean."],"exampleFix":"// before\nrecorder.register(name, configSupplier.get()); // may be null\n// after\nTlsConfiguration cfg = configSupplier.get();\nif (cfg != null) { recorder.register(name, cfg); }","handlingStrategy":"type-guard","validationCode":"Objects.requireNonNull(config, \"TlsConfiguration must be initialized before registration\");\nif (name == null || name.isBlank()) throw new IllegalArgumentException(\"name required\");","typeGuard":"boolean isRegisterable(String name, TlsConfiguration cfg) {\n    return name != null && !name.isBlank() && cfg != null;\n}","tryCatchPattern":"try {\n    recorder.register(name, config);\n} catch (IllegalArgumentException e) {\n    log.errorf(\"Failed to register TLS config '%s': %s\", name, e.getMessage());\n}","preventionTips":["Always construct or resolve the TlsConfiguration before calling register; skip registration when absent.","Return Optional<TlsConfiguration> from configuration suppliers and unwrap explicitly.","Cover registration paths with unit tests using a null-configuration case."],"tags":["tls","quarkus","illegal-argument","null-check"],"backgroundTag":"null-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"}