{"record":{"id":"98ea3163227e58a5","repo":"quarkusio/quarkus","slug":"contextual-parameter-must-not-be-null","errorCode":null,"errorMessage":"Contextual parameter must not be null","messagePattern":"Contextual parameter must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java","lineNumber":111,"sourceCode":"        } else {\n            result = contextState;\n        }\n        return result;\n    }\n\n    @Override\n    public Class<? extends Annotation> getScope() {\n        return TransactionScoped.class;\n    }\n\n    @Override\n    @SuppressWarnings(\"unchecked\")\n    public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) {\n        if (!isActive()) {\n            throw new ContextNotActiveException();\n        }\n        if (contextual == null) {\n            throw new IllegalArgumentException(\"Contextual parameter must not be null\");\n        }\n\n        TransactionSynchronizationRegistry registryInstance = transactionSynchronizationRegistry.get();\n        TransactionContextState contextState;\n\n        // Prevent concurrent contextState creation from multiple threads sharing the same transaction,\n        // since TransactionSynchronizationRegistry has no atomic compute if absent mechanism.\n        transactionLock.lock();\n\n        try {\n            contextState = (TransactionContextState) registryInstance.getResource(TRANSACTION_CONTEXT_MARKER);\n\n            if (contextState == null) {\n                contextState = new TransactionContextState(getCurrentTransaction());\n                registryInstance.putResource(TRANSACTION_CONTEXT_MARKER, contextState);\n            }\n\n        } finally {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java#L93-L129","documentation":"TransactionContext.get() validates its Contextual parameter and throws IllegalArgumentException(\"Contextual parameter must not be null\") when null is passed. This guards the CDI SPI contract: the container must never pass a null Contextual; a null means a broken custom CDI extension or reflective misuse.","triggerScenarios":"Directly calling TransactionContext (or a subclass/stand-in) .get(null, creationalContext) — typically from custom CDI extension code, tests, or reflection rather than normal application code.","commonSituations":"Custom CDI portable extensions or proxies invoking context APIs with unresolved beans; unit tests simulating the container and forgetting to build a real Contextual; framework misintegration.","solutions":["Pass the actual Contextual instance obtained from the CDI container/BeanManager (e.g. beans.resolve, manager.createCreationalContext)","Fix the custom extension/test code that passes null","If introspecting, guard for null before calling get()"],"exampleFix":"// before\nObject instance = context.get(null, creationalContext);\n// after\nBean<T> bean = (Bean<T>) manager.resolve(manager.getBeans(type));\nObject instance = context.get(bean, manager.createCreationalContext(bean));","handlingStrategy":"validation","validationCode":"if (contextual == null) throw new IllegalArgumentException(\"Contextual parameter must not be null\");","typeGuard":"boolean hasContextual(Contextual<?> c) { return c != null; }","tryCatchPattern":"try { v = ctx.get(contextual, cc); } catch (IllegalArgumentException e) { /* fix container/extension passing null Contextual */ }","preventionTips":["Never call CDI Context SPI methods directly with hand-built arguments; obtain Contextual from BeanManager","Null-check parameters in custom CDI extensions before delegating to context implementations","Cover custom extension code with tests exercising context.get()"],"tags":["narayana-jta","cdi","illegal-argument","null-check"],"backgroundTag":"invalid-argument-null","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"}