{"record":{"id":"9ee264cc6d831147","repo":"quarkusio/quarkus","slug":"cannot-call-getvalue-at-deployment-time","errorCode":null,"errorMessage":"Cannot call getValue() at deployment time","messagePattern":"Cannot call getValue\\(\\) at deployment time","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/runtime/src/main/java/io/quarkus/runtime/RuntimeValue.java","lineNumber":25,"sourceCode":" * and passed between recorders.\n *\n */\npublic class RuntimeValue<T> {\n\n    private final T value;\n\n    public RuntimeValue(T value) {\n        Objects.requireNonNull(value);\n        this.value = value;\n    }\n\n    public RuntimeValue() {\n        this.value = null;\n    }\n\n    public T getValue() {\n        if (value == null) {\n            throw new IllegalStateException(\"Cannot call getValue() at deployment time\");\n        }\n        return value;\n    }\n}\n","sourceCodeStart":7,"sourceCodeEnd":30,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/runtime/src/main/java/io/quarkus/runtime/RuntimeValue.java#L7-L30","documentation":"RuntimeValue.getValue() throws IllegalStateException when the wrapped value is null, which for a recorder-created RuntimeValue means the underlying runtime object has not been created yet — i.e. the method is being invoked at deployment time instead of at runtime. Recorder code must only call getValue() inside recorded bytecode that executes at runtime.","triggerScenarios":"Calling runtimeValue.getValue() directly inside a @Recorder method or build step at deployment time; reading the value before the recording produced the target object.","commonSituations":"Extension authors writing recorders who accidentally dereference the RuntimeValue during build; passing a no-arg-constructed RuntimeValue (new RuntimeValue()) and reading it immediately.","solutions":["Move the getValue() call into code that is recorded (RecordedFunction/bytecode) so it executes at runtime.","Do not construct new RuntimeValue() manually; return values from recorder methods so the value is set.","At deployment time, operate on the RuntimeValue handle, not its contents.","If you need the value during the build, use a different build item mechanism rather than getValue()."],"exampleFix":"// before (recorder, deployment time)\nvar svc = runtimeValue.getValue();\nserviceConfig.call(svc);\n// after\nserviceConfig.call(runtimeValue, \"getValue\"); // record the call for runtime","handlingStrategy":"validation","validationCode":"// in recorder/deployment code, never call getValue(); assert you are recording instead:\n// bad: runtimeValue.getValue();  good: pass runtimeValue to recorded invocations","typeGuard":"boolean safeToRead(RuntimeValue<?> rv) { return rv != null && isRuntimePhase(); } // isRuntimePhase(): true only in runtime-init/recorded code","tryCatchPattern":"try { return runtimeValue.getValue(); } catch (IllegalStateException e) { throw new IllegalStateException(\"called getValue() at deployment time; move to recorded runtime code\", e); }","preventionTips":["Never call getValue() inside @Recorder methods or build steps","Let recorder methods return RuntimeValue instead of constructing new RuntimeValue() manually","Operate on the handle during the build; dereference only at runtime"],"tags":["quarkus","recorder","deployment-time","build-time"],"backgroundTag":"getvalue-at-deployment-time","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"}