alibaba/arthas · error · IllegalArgumentException

classPattern is required for record operation

Error message

classPattern is required for record operation

What it means

The record action requires classPattern to identify which class to instrument for recording method invocations. Without it Arthas cannot set up the TimeTunnel watch point.

Source

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

                break;
            default:
                throw new IllegalArgumentException("Unsupported action: " + ttAction +
                        ". Supported actions: record(t), list(l), info(i), search(s), replay(p), delete(d), deleteAll(da)");
        }

        return executeStreamable(toolContext, cmd.toString(), execCount, DEFAULT_POLL_INTERVAL_MS, timeoutSeconds * 1000,
                "TimeTunnel recording completed successfully");
    }

    /**
     * 验证参数
     */
    private void validateParameters(String action, String classPattern, String methodPattern, 
                                   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) {

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Provide classPattern with a class name expression (e.g., demo.MathGame or *Test).
  2. Remember that action defaults to record when omitted, so classPattern and methodPattern are almost always needed.
  3. If you intended a different action (list, info, etc.), specify it explicitly.

Example fix

// before
tt(action="record", methodPattern="primeFactors")
// after
tt(action="record", classPattern="demo.MathGame", methodPattern="primeFactors")
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

try {
    String result = timeTunnel(action, classPattern, methodPattern, ...);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("classPattern")) {
        // classPattern missing for record — provide a class name expression
    }
}

Prevention

When it happens

Trigger: Calling the tt tool with action=record (the default when action is omitted) while classPattern is null or blank. Validated in validateParameters at line 111-113.

Common situations: User omits classPattern expecting a wildcard default; MCP client drops the field; user relies on the default action=record but forgets the required class argument.

Related errors


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