{"record":{"id":"f99567eedb244c34","repo":"quarkusio/quarkus","slug":"key-cannot-be-null","errorCode":null,"errorMessage":"Key cannot be null","messagePattern":"Key cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/runtime/src/main/java/io/quarkus/runtime/ValueRegistryImpl.java","lineNumber":35,"sourceCode":" * <p>\n * Each Quarkus application has its own separate instance, created on application start. The {@link ValueRegistry} is\n * then stored in the {@link io.quarkus.runtime.StartupContext} before any recorders are executed, so that it can be\n * injected into the recorders' constructors as a {@link RuntimeValue}.\n *\n * @see Application#Application(boolean)\n * @see \"io.quarkus.deployment.steps.MainClassBuildStep#build for storage\"\n * @see \"io.quarkus.deployment.ExtensionLoader#loadStepsFrom for retrieval\"\n * @see \"io.quarkus.deployment.recording.ObjectLoader\"\n */\npublic class ValueRegistryImpl implements ValueRegistry {\n    private final Map<String, RuntimeInfo<?>> values = new ConcurrentHashMap<>();\n\n    private ValueRegistryImpl() {\n    }\n\n    public <T> void register(final RuntimeKey<T> key, final T value) {\n        if (key == null || key.key() == null) {\n            throw new IllegalArgumentException(\"Key cannot be null\");\n        }\n        if (value == null) {\n            throw new IllegalArgumentException(\"Value cannot be null\");\n        }\n        registerInfo(key, SimpleRuntimeInfo.of(value));\n    }\n\n    public <T> void registerInfo(final RuntimeKey<T> key, final RuntimeInfo<T> runtimeInfo) {\n        if (key == null || key.key() == null) {\n            throw new IllegalArgumentException(\"Key cannot be null\");\n        }\n        if (runtimeInfo == null) {\n            throw new IllegalArgumentException(\"Value cannot be null\");\n        }\n        RuntimeInfo<?> mapValue = values.putIfAbsent(key.key(), runtimeInfo);\n        if (mapValue != null) {\n            throw new IllegalArgumentException(\"Key already registered \" + key.key());\n        }","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/runtime/src/main/java/io/quarkus/runtime/ValueRegistryImpl.java#L17-L53","documentation":"Thrown by ValueRegistryImpl.register when a recorder attempts to store a RuntimeValue under a null RuntimeKey. The registry maps RuntimeKey instances to RuntimeInfo entries created by recorders at application startup; a null key has no storage identity, so the registration guard rejects it before the internal map is touched. It indicates a recorder bug (passing an uninitialized key) rather than a user configuration problem.","triggerScenarios":"Calling register(null, value) or register(keyWhoseKeyIsNull, value) — typically from extension code building runtime values with a mis-constructed RuntimeKey.","commonSituations":"Extension code constructing RuntimeKey dynamically where a name/config lookup returned null; refactoring that dropped key initialization.","solutions":["Ensure the RuntimeKey passed to register is non-null and was created with a non-null key string.","Validate keys before registering, or fail earlier at key construction time.","Check the extension recorder that produces the RuntimeKey for a null return value."],"exampleFix":"// before\nregistry.register(key, value); // key may be null\n// after\nObjects.requireNonNull(key, \"key\");\nObjects.requireNonNull(key.key(), \"key.key()\");\nregistry.register(key, value);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(key, \"RuntimeKey must not be null\");\nObjects.requireNonNull(key.key(), \"RuntimeKey.key() must not be null\");\nregistry.register(key, value);","typeGuard":"boolean validKey(RuntimeKey<?> k) { return k != null && k.key() != null; }","tryCatchPattern":null,"preventionTips":["Validate RuntimeKey construction at its creation site","Never pass possibly-null keys to register()","Check dynamic key-producing code for null lookups"],"tags":["quarkus","registry","null-argument","validation"],"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"}