alibaba/Sentinel · error · IllegalArgumentException
Bad invocation instance
Error message
Bad invocation instance
What it means
Thrown by DubboUtils.getApplication() in the Sentinel Apache Dubbo 2.x adapter when the passed org.apache.dubbo.rpc.Invocation is null or its attachment map is null. The utility reads the consumer application name from the 'dubboApplication' attachment on every Dubbo invocation for flow-control origin tracking, so a malformed Invocation is rejected immediately with IllegalArgumentException. It signals a programming error or a broken filter chain, not a runtime flow event.
Source
Thrown at sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboUtils.java:32
* limitations under the License.
*/
package com.alibaba.csp.sentinel.adapter.dubbo;
import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
import com.alibaba.csp.sentinel.util.StringUtil;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
/**
* @author Eric Zhao
*/
public final class DubboUtils {
public static final String SENTINEL_DUBBO_APPLICATION_KEY = "dubboApplication";
public static String getApplication(Invocation invocation, String defaultValue) {
if (invocation == null || invocation.getAttachments() == null) {
throw new IllegalArgumentException("Bad invocation instance");
}
return invocation.getAttachment(SENTINEL_DUBBO_APPLICATION_KEY, defaultValue);
}
public static String getMethodResourceName(Invoker<?> invoker, Invocation invocation){
return getMethodResourceName(invoker, invocation, false);
}
public static String getMethodResourceName(Invoker<?> invoker, Invocation invocation, Boolean useGroupAndVersion) {
StringBuilder buf = new StringBuilder(64);
String interfaceResource = useGroupAndVersion ? invoker.getUrl().getColonSeparatedKey() : invoker.getInterface().getName();
buf.append(interfaceResource)
.append(":")
.append(invocation.getMethodName())
.append("(");
boolean isFirst = true;
for (Class<?> clazz : invocation.getParameterTypes()) {
if (!isFirst) {View on GitHub (pinned to a3f40ba8e9)
Solutions
- If you called DubboUtils directly, guard with 'if (invocation == null || invocation.getAttachments() == null) return default;' before calling
- In unit tests, stub the mock: when(invocation.getAttachments()).thenReturn(new HashMap<>())
- Check custom Dubbo filter order (sentinel.adapter.filter.order) so the Sentinel filter runs after Dubbo's own context filters
- Verify you are not passing an InvokerInvocationHandler-created invocation before the RPC layer initialized it
Example fix
// before
String app = DubboUtils.getApplication(invocation, "default");
// after
String app = (invocation != null && invocation.getAttachments() != null)
? DubboUtils.getApplication(invocation, "default")
: "default"; Defensive patterns
Strategy: validation
Validate before calling
if (invocation == null || invocation.getAttachments() == null) {
return defaultValue;
}
return DubboUtils.getApplication(invocation, defaultValue); Prevention
- Always null-check Invocation and its attachment map before calling adapter utilities
- In unit tests, stub getAttachments() to return a HashMap rather than leaving it default (null)
When it happens
Trigger: Calling DubboUtils.getApplication(null, default) or getApplication(invocation, default) where invocation.getAttachments() returns null; indirectly via SentinelDubboProviderFilter/ConsumerFilter when a custom Dubbo filter replaced or wrapped the Invocation with one that has no attachment map.
Common situations: Unit tests with mocked Invocation objects that don't stub getAttachments(); custom Dubbo filter ordering that puts Sentinel's filter before the RPC framework populates attachments; upgrading Dubbo versions where the Invocation implementation differs.
Related errors
- Bad invocation instance
- Bad invocation instance
- ${name} is null or empty
- ${name} is null
- Publisher type is not supported: ${canonicalName}
AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14).
Data as JSON: /api/errors/a69f2cc1342fafa8.
Report an issue: GitHub.