alibaba/Sentinel · error · IllegalArgumentException

Bad invocation instance

Error message

Bad invocation instance

What it means

Thrown by DubboUtils.getApplication() in the legacy Sentinel Dubbo (com.alibaba.dubbo) adapter when the Invocation is null or its attachment map is null. The utility reads the consumer's application name from the 'dubboApplication' attachment to attribute traffic origins. It is a fail-fast programming-error signal (IllegalArgumentException), not a flow-control event.

Source

Thrown at sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboUtils.java:29

 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.alibaba.csp.sentinel.adapter.dubbo;

import com.alibaba.dubbo.rpc.Invocation;

/**
 * @author Eric Zhao
 */
public final class DubboUtils {

    public static final String 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(DUBBO_APPLICATION_KEY, defaultValue);
    }

    private DubboUtils() {}
}

View on GitHub (pinned to a3f40ba8e9)

Solutions

  1. Guard the call: check invocation != null && invocation.getAttachments() != null before invoking
  2. Fix test mocks to return a non-null attachment map
  3. Inspect custom Dubbo filters for Invocation replacement that drops attachments

Example fix

// before
String app = DubboUtils.getApplication(invocation, "unknown");

// after
String app = (invocation != null && invocation.getAttachments() != null)
    ? DubboUtils.getApplication(invocation, "unknown")
    : "unknown";
Defensive patterns

Strategy: validation

Validate before calling

if (invocation != null && invocation.getAttachments() != null) {
    app = DubboUtils.getApplication(invocation, "unknown");
} else {
    app = "unknown";
}

Prevention

When it happens

Trigger: Calling DubboUtils.getApplication(null, default); passing an Invocation whose getAttachments() returns null; SentinelDubboProviderFilter/ConsumerFilter invoked with a hand-constructed or mocked Invocation that never had attachments populated.

Common situations: Unit tests of the old Alibaba Dubbo adapter with incomplete mocks; custom filters on the legacy Dubbo (<=2.6.x / com.alibaba) chain stripping attachments; null Invocation leak from a broken async Dubbo callback.

Related errors


AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14). Data as JSON: /api/errors/5d2de1210afcc851. Report an issue: GitHub.