{"record":{"id":"6c82a1f160a3fc17","repo":"quarkusio/quarkus","slug":"can-only-be-called-at-runtime","errorCode":null,"errorMessage":"Can only be called at runtime","messagePattern":"Can only be called at runtime","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/builditem/RawCommandLineArgumentsBuildItem.java","lineNumber":36,"sourceCode":"\n    /**\n     * As this object directly implements ReturnedProxy it can be\n     * passed into bytecode recorders. The runtime value of the command line parameters\n     * are placed directly into the startup context under this key.\n     */\n    @Override\n    public String __returned$proxy$key() {\n        return StartupContext.RAW_COMMAND_LINE_ARGS;\n    }\n\n    @Override\n    public boolean __static$$init() {\n        return true;\n    }\n\n    @Override\n    public String[] get() {\n        throw new IllegalStateException(\"Can only be called at runtime\");\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":39,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/builditem/RawCommandLineArgumentsBuildItem.java#L18-L39","documentation":"RawCommandLineArgumentsBuildItem.get() is overridden to always throw IllegalStateException because the raw command line is only meaningful at runtime; build-time consumers must not read it. This is a deliberate misuse guard.","triggerScenarios":"Calling get() on a RawCommandLineArgumentsBuildItem instance during the deployment (build-time) phase, e.g. inside a @BuildStep consuming this build item.","commonSituations":"A build step tries to inspect the raw application command-line arguments to make build-time decisions, which Quarkus forbids since arguments only exist at launch time.","solutions":["Remove the get() call from build-time code; process raw args only at runtime","Consume RuntimeConfigSetupCompleteBuildItem or other runtime-phase hooks if runtime access is needed","Use a different build item that exposes build-time-visible information"],"exampleFix":"// before (build step)\nString[] args = rawCommandLineArgumentsBuildItem.get();\n// after\n// read args at runtime via a runtime recordable/bean instead","handlingStrategy":"try-catch","validationCode":"if (buildItem instanceof RawCommandLineArgumentsBuildItem && isBuildTime()) { /* do not call get() */ }","typeGuard":null,"tryCatchPattern":"try { args = item.get(); } catch (IllegalStateException e) { log.warn(\"Raw command line is runtime-only\", e); args = new String[0]; }","preventionTips":["Never read RawCommandLineArgumentsBuildItem in @BuildStep code","Handle command-line arguments at runtime via runtime APIs","Check whether a build item is runtime-only before consuming its getters"],"tags":["build-time","illegal-state","misuse"],"backgroundTag":"build-time-only-api-misuse","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"}