{"record":{"id":"bb00a8b5255c1671","repo":"quarkusio/quarkus","slug":"not-allowed-to-put-key-key-interceptor-bindings","errorCode":null,"errorMessage":"Not allowed to put key '${KEY_INTERCEPTOR_BINDINGS}' in the context data map","messagePattern":"Not allowed to put key '(.+?)' in the context data map","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ContextDataMap.java","lineNumber":122,"sourceCode":"        return false;\n    }\n\n    @Override\n    public Set<String> keySet() {\n        if (delegate == null) {\n            return Set.of(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);\n        } else {\n            Set<String> set = new HashSet<>(delegate.size() + 1);\n            set.addAll(delegate.keySet());\n            set.add(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);\n            return set;\n        }\n    }\n\n    @Override\n    public void putAll(Map<? extends String, ? extends Object> m) {\n        if (m.containsKey(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS)) {\n            throw new IllegalArgumentException(\n                    \"Not allowed to put key '\" + ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS + \"' in the context data map\");\n        }\n        getDelegateForWrite(m.size()).putAll(m);\n    }\n\n    @Override\n    public Object remove(Object key) {\n        if (ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS.equals(key)) {\n            throw new IllegalArgumentException(\"Not allowed to remove key '\" + ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS\n                    + \"' from the context data map\");\n        } else if (delegate == null) {\n            return null;\n        } else {\n            return delegate.remove(key);\n        }\n    }\n\n    @Override","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ContextDataMap.java#L104-L140","documentation":"ContextDataMap.putAll() blocks bulk insertion of the reserved key ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS (\"org.jboss.weld.interceptor.bindings\"-style reserved key for interceptor bindings metadata). The interceptor bindings in the context data are framework-managed; letting user code overwrite them via putAll would corrupt interceptor resolution, so ArC throws IllegalArgumentException.","triggerScenarios":"Calling getContextData().putAll(someMap) where someMap contains the reserved KEY_INTERCEPTOR_BINDINGS key — e.g. copying a full InvocationContext's data into another one.","commonSituations":"Interceptor chaining/delegation code that copies one invocation context's data map into another; test utilities that snapshot and replay context data wholesale.","solutions":["Filter out the reserved key before putAll: build a new map excluding ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS.","Copy entries individually with put() for only the keys you need to transfer.","Never treat interceptor bindings as application data; read them via the API instead of copying them."],"exampleFix":"// before\ntarget.getContextData().putAll(source.getContextData());\n\n// after\nMap<String, Object> filtered = new HashMap<>(source.getContextData());\nfiltered.remove(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);\ntarget.getContextData().putAll(filtered);","handlingStrategy":"validation","validationCode":"Map<String, Object> safe = new HashMap<>(source);\nsafe.remove(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);\nif (safe.containsKey(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS)) {\n    throw new IllegalStateException(\"reserved key present\");\n}","typeGuard":"static boolean containsReservedKey(Map<? extends String, ?> m) {\n    return m.containsKey(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);\n}","tryCatchPattern":"try {\n    contextData.putAll(data);\n} catch (IllegalArgumentException e) {\n    if (!e.getMessage().contains(\"Not allowed to put key\")) throw e;\n    // strip reserved key and retry\n}","preventionTips":["Always filter ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS before bulk copies.","Copy only your own named keys between invocation contexts.","Centralize context-data copying in one utility that enforces the filter."],"tags":["cdi","interceptor","reserved-key","quarkus-arc"],"backgroundTag":"reserved-key-modification","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"}