quarkusio/quarkus · error · IllegalArgumentException

Not allowed to put key '${KEY_INTERCEPTOR_BINDINGS}' in the

Error message

Not allowed to put key '${KEY_INTERCEPTOR_BINDINGS}' in the context data map

What it means

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.

Source

Thrown at independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ContextDataMap.java:122

        return false;
    }

    @Override
    public Set<String> keySet() {
        if (delegate == null) {
            return Set.of(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);
        } else {
            Set<String> set = new HashSet<>(delegate.size() + 1);
            set.addAll(delegate.keySet());
            set.add(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);
            return set;
        }
    }

    @Override
    public void putAll(Map<? extends String, ? extends Object> m) {
        if (m.containsKey(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS)) {
            throw new IllegalArgumentException(
                    "Not allowed to put key '" + ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS + "' in the context data map");
        }
        getDelegateForWrite(m.size()).putAll(m);
    }

    @Override
    public Object remove(Object key) {
        if (ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS.equals(key)) {
            throw new IllegalArgumentException("Not allowed to remove key '" + ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS
                    + "' from the context data map");
        } else if (delegate == null) {
            return null;
        } else {
            return delegate.remove(key);
        }
    }

    @Override

View on GitHub (pinned to e1c734241f)

Solutions

  1. Filter out the reserved key before putAll: build a new map excluding ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS.
  2. Copy entries individually with put() for only the keys you need to transfer.
  3. Never treat interceptor bindings as application data; read them via the API instead of copying them.

Example fix

// before
target.getContextData().putAll(source.getContextData());

// after
Map<String, Object> filtered = new HashMap<>(source.getContextData());
filtered.remove(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);
target.getContextData().putAll(filtered);
Defensive patterns

Strategy: validation

Validate before calling

Map<String, Object> safe = new HashMap<>(source);
safe.remove(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);
if (safe.containsKey(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS)) {
    throw new IllegalStateException("reserved key present");
}

Type guard

static boolean containsReservedKey(Map<? extends String, ?> m) {
    return m.containsKey(ArcInvocationContext.KEY_INTERCEPTOR_BINDINGS);
}

Try / catch

try {
    contextData.putAll(data);
} catch (IllegalArgumentException e) {
    if (!e.getMessage().contains("Not allowed to put key")) throw e;
    // strip reserved key and retry
}

Prevention

When it happens

Trigger: Calling getContextData().putAll(someMap) where someMap contains the reserved KEY_INTERCEPTOR_BINDINGS key — e.g. copying a full InvocationContext's data into another one.

Common situations: Interceptor chaining/delegation code that copies one invocation context's data map into another; test utilities that snapshot and replay context data wholesale.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/bb00a8b5255c1671. Report an issue: GitHub.