alibaba/Sentinel · error · IllegalArgumentException
Bad invocation instance
Error message
Bad invocation instance
What it means
Thrown by DubboUtils.getApplication() in the Sentinel Apache Dubbo 3.x adapter when the Invocation is null or its attachments map is null. The adapter resolves the caller's application name: first from the Dubbo 'remoteApplication' attachment (also falling back to RpcContext.getServerAttachment()), then from the legacy 'dubboApplication' attachment. A null Invocation or null attachment map cannot be processed, so it fails fast with IllegalArgumentException.
Source
Thrown at sentinel-adapter/sentinel-apache-dubbo3-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo3/DubboUtils.java:37
import com.alibaba.csp.sentinel.util.StringUtil;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcContext;
import static org.apache.dubbo.common.constants.CommonConstants.REMOTE_APPLICATION_KEY;
/**
* @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");
}
// 1. try to get application from dubbo context
String remoteApplication = invocation.getAttachment(REMOTE_APPLICATION_KEY);
if (StringUtils.isEmpty(remoteApplication)) {
remoteApplication = RpcContext.getServerAttachment().getAttachment(REMOTE_APPLICATION_KEY);
}
if (StringUtils.isNotEmpty(remoteApplication)) {
return remoteApplication;
}
// 2. fallback to sentinel application
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) {View on GitHub (pinned to a3f40ba8e9)
Solutions
- Null-guard before calling: only invoke getApplication when invocation != null && invocation.getAttachments() != null
- In tests, stub both invocation.getAttachments() and (if needed) RpcContext.getServerAttachment() to return non-null maps
- Ensure the Sentinel Dubbo 3 filter is on the provider/consumer filter chain after Dubbo's context-establishing filters
Example fix
// before
String app = DubboUtils.getApplication(invocation, defaultValue);
// after
String app = (invocation != null && invocation.getAttachments() != null)
? DubboUtils.getApplication(invocation, defaultValue)
: defaultValue; Defensive patterns
Strategy: validation
Validate before calling
if (invocation == null || invocation.getAttachments() == null) {
return defaultValue;
}
return DubboUtils.getApplication(invocation, defaultValue); Prevention
- Stub both invocation attachments and RpcContext.getServerAttachment() in Dubbo 3 tests
- Confirm filter order so the Sentinel filter sees a fully initialized Invocation
When it happens
Trigger: Calling DubboUtils.getApplication(null, default) directly; passing an Invocation whose getAttachments() returns null; invoking the adapter's filters in unit tests without a real Dubbo 3 RPC context (RpcContext.getServerAttachment() empty and unstubbed Invocation).
Common situations: Migrating from Dubbo 2.x to Dubbo 3 adapter where mocks no longer match; unit tests of Dubbo3 filters lacking stubbed attachments; custom filters wrapping Invocation and dropping attachments.
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/f880f2010d15c380.
Report an issue: GitHub.