{"record":{"id":"b846acf25c442b04","repo":"quarkusio/quarkus","slug":"not-allowed-to-remove-key-key-interceptor-bindi","errorCode":null,"errorMessage":"Not allowed to remove key '${KEY_INTERCEPTOR_BINDINGS}' from the context data map","messagePattern":"Not allowed to remove key '(.+?)' from 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":131,"sourceCode":"            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\n    public int size() {\n        return getDelegateForRead().size() + 1;\n    }\n\n    @Override\n    public Collection<Object> values() {\n        if (delegate == null) {\n            return Set.of(interceptorBindings);\n        } else {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ContextDataMap.java#L113-L149","documentation":"ContextDataMap.remove() refuses to remove ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS, the framework-managed entry holding the current interceptor bindings for the invocation. Removing it would break subsequent interceptor metadata lookups, so ArC throws IllegalArgumentException; removing any other key is allowed.","triggerScenarios":"Calling getContextData().remove(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS) or a bulk cleanup loop that tries to remove every key, including the reserved one.","commonSituations":"Cleanup code iterating over contextData.keySet() and removing all entries after an invocation; code that copied a Weld pattern assuming the bindings key is user-deletable.","solutions":["Skip the reserved key in removal loops (compare against ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS).","Remove only your own named keys instead of clearing everything.","Store interceptor-related data under your own key if you need to manage it separately."],"exampleFix":"// before\nfor (String key : contextData.keySet()) { contextData.remove(key); } // hits reserved key\n\n// after\ncontextData.keySet().removeIf(k -> !ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS.equals(k));","handlingStrategy":"validation","validationCode":"if (ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS.equals(key)) {\n    throw new IllegalStateException(\"cannot remove reserved interceptor bindings key\");\n}\ncontextData.remove(key);","typeGuard":"static boolean isRemovableKey(Object key) {\n    return !ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS.equals(key);\n}","tryCatchPattern":"try {\n    contextData.remove(key);\n} catch (IllegalArgumentException e) {\n    if (!e.getMessage().contains(\"Not allowed to remove key\")) throw e;\n    // skip reserved key\n}","preventionTips":["Never write removal loops that iterate all keys of the context data map.","Use removeIf with a filter excluding the reserved key.","Track the keys your code added and remove exactly those."],"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"}