{"record":{"id":"074c498a1acbe2c7","repo":"quarkusio/quarkus","slug":"oidc-client-feature-is-disabled-with-quarkus-oidc","errorCode":null,"errorMessage":"OIDC client feature is disabled with `quarkus.oidc-client.enabled=false` but the initTokens() method is called.","messagePattern":"OIDC client feature is disabled with `quarkus\\.oidc-client\\.enabled=false` but the initTokens\\(\\) method is called\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/AbstractTokensProducer.java","lineNumber":75,"sourceCode":"\n        initTokens();\n        if (!isForceNewTokens()) {\n            oidcClients.registerTokenRefresh(oidcClient, new Supplier<Uni<Tokens>>() {\n                @Override\n                public Uni<Tokens> get() {\n                    return getTokens();\n                }\n            });\n        }\n    }\n\n    protected boolean isClientFeatureDisabled() {\n        return !oidcClientBuildTimeConfig.enabled();\n    }\n\n    protected void initTokens() {\n        if (isClientFeatureDisabled()) {\n            throw new IllegalStateException(\"OIDC client feature is disabled with `quarkus.oidc-client.enabled=false`\"\n                    + \" but the initTokens() method is called.\");\n        }\n        if (earlyTokenAcquisition) {\n            // Skip early token acquisition for deferred clients - they will recover on first request\n            if (oidcClient instanceof DeferredOidcClient) {\n                LOG.debug(\"Skipping early token acquisition for deferred OIDC client\");\n                return;\n            }\n            tokensHelper.initTokens(oidcClient, additionalParameters());\n        }\n    }\n\n    public Uni<Tokens> getTokens() {\n        return getTokens(additionalParameters());\n    }\n\n    public Uni<Tokens> getTokens(Map<String, String> additionalParameters) {\n        if (isClientFeatureDisabled()) {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/AbstractTokensProducer.java#L57-L93","documentation":"AbstractTokensProducer.initTokens() checks the build-time flag quarkus.oidc-client.enabled. When the OIDC client feature has been disabled at build time but a producer still calls initTokens(), an IllegalStateException is thrown because token acquisition cannot work in a disabled feature.","triggerScenarios":"An application includes a class extending AbstractTokensProducer (e.g. a custom TokensProducer or OidcClients producer) and its init() invokes initTokens() while quarkus.oidc-client.enabled=false at build time.","commonSituations":"Disabling the OIDC client extension to trim the build but leaving a @PostConstruct that calls initTokens(); shared library code that unconditionally initializes tokens.","solutions":["Remove the initTokens() call (or the producer bean) from code paths active when the feature is disabled.","Guard the call: only call initTokens() when isClientFeatureDisabled() is false.","If tokens are actually needed, re-enable the feature by removing quarkus.oidc-client.enabled=false (or set it to true)."],"exampleFix":"// before\n@PostConstruct\nvoid init() { initTokens(); }\n\n// after\n@PostConstruct\nvoid init() {\n    if (!isClientFeatureDisabled()) {\n        initTokens();\n    }\n}","handlingStrategy":"try-catch","validationCode":"if (producer.isClientFeatureDisabled()) {\n    return; // skip token init\n}","typeGuard":null,"tryCatchPattern":"try {\n    initTokens();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"oidc-client.enabled=false\")) {\n        LOG.warn(\"OIDC client disabled; skipping token initialization\");\n    } else throw e;\n}","preventionTips":["Keep initTokens() and quarkus.oidc-client.enabled=true consistent.","Grep for initTokens() callers when disabling the extension.","Document that producers require the feature enabled."],"tags":["oidc-client","build-time-config","lifecycle"],"backgroundTag":"feature-disabled-at-build-time","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"}