alibaba/arthas · error · IllegalArgumentException

search operation requires searchExpression parameter

Error message

search operation requires searchExpression parameter

What it means

The search action requires searchExpression, an OGNL expression evaluated against each recorded invocation to filter results.

Source

Thrown at core/src/main/java/com/taobao/arthas/core/mcp/tool/function/monitor200/TimeTunnelTool.java:126

                                   Integer index, String searchExpression) {
        switch (action) {
            case "record":
                if (classPattern == null || classPattern.trim().isEmpty()) {
                    throw new IllegalArgumentException("classPattern is required for record operation");
                }
                if (methodPattern == null || methodPattern.trim().isEmpty()) {
                    throw new IllegalArgumentException("methodPattern is required for record operation");
                }
                break;
            case "info":
            case "replay":
                if (index == null) {
                    throw new IllegalArgumentException(action + " operation requires index parameter");
                }
                break;
            case "search":
                if (searchExpression == null || searchExpression.trim().isEmpty()) {
                    throw new IllegalArgumentException("search operation requires searchExpression parameter");
                }
                break;
            case "delete":
                if (index == null) {
                    throw new IllegalArgumentException("delete operation requires index parameter");
                }
                break;
            case "list":
            case "deleteall":
                break;
            default:
                throw new IllegalArgumentException("Unsupported action: " + action);
        }
    }

    /**
     * 标准化操作类型
     */

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Provide a valid OGNL searchExpression (e.g., 'method.name=="primeFactors"' or 'params[0]>0').
  2. Use tt(action="list") to see all recordings without filtering.

Example fix

// before
tt(action="search")
// after
tt(action="search", searchExpression='method.name=="primeFactors"')
Defensive patterns

Strategy: validation

Validate before calling

// Before calling tt search, validate searchExpression
if ("search".equals(normalizedAction)
        && (searchExpression == null || searchExpression.trim().isEmpty())) {
    throw new IllegalArgumentException("searchExpression is required for tt search");
}

Try / catch

try {
    String result = timeTunnel(action, ..., searchExpression, ...);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("searchExpression")) {
        // searchExpression missing for search action
    }
}

Prevention

When it happens

Trigger: Calling tt with action=search while searchExpression is null or blank.

Common situations: User forgets the OGNL filter expression; passes an empty string.

Related errors


AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14). Data as JSON: /api/errors/90c28b66ea556ec6. Report an issue: GitHub.