alibaba/ARouter · error · HandlerException

Parameter invalid!

Error message

Parameter invalid!

What it means

_ARouter.build(Uri uri) throws HandlerException when the Uri is null or its string form is empty. A Uri is required to derive path and group for the Postcard, so it is validated before PathReplaceService.forUri is consulted.

Source

Thrown at arouter-api/src/main/java/com/alibaba/android/arouter/launcher/_ARouter.java:199

     */
    protected Postcard build(String path) {
        if (TextUtils.isEmpty(path)) {
            throw new HandlerException(Consts.TAG + "Parameter is invalid!");
        } else {
            PathReplaceService pService = ARouter.getInstance().navigation(PathReplaceService.class);
            if (null != pService) {
                path = pService.forString(path);
            }
            return build(path, extractGroup(path), true);
        }
    }

    /**
     * Build postcard by uri
     */
    protected Postcard build(Uri uri) {
        if (null == uri || TextUtils.isEmpty(uri.toString())) {
            throw new HandlerException(Consts.TAG + "Parameter invalid!");
        } else {
            PathReplaceService pService = ARouter.getInstance().navigation(PathReplaceService.class);
            if (null != pService) {
                uri = pService.forUri(uri);
            }
            return new Postcard(uri.getPath(), extractGroup(uri.getPath()), uri, null);
        }
    }

    /**
     * Build postcard by path and group
     */
    protected Postcard build(String path, String group, Boolean afterReplace) {
        if (TextUtils.isEmpty(path) || TextUtils.isEmpty(group)) {
            throw new HandlerException(Consts.TAG + "Parameter is invalid!");
        } else {
            if (!afterReplace) {
                PathReplaceService pService = ARouter.getInstance().navigation(PathReplaceService.class);

View on GitHub (pinned to 84f451d244)

Solutions

  1. Null/empty-check the Uri before calling build
  2. For activity deep links, check getIntent() != null && getIntent().getData() != null
  3. Sanitize external URL payloads before converting to Uri

Example fix

// before
Uri uri = Uri.parse(pushPayload.getUrl());
ARouter.getInstance().build(uri).navigation(); // HandlerException if empty
// after
String url = pushPayload.getUrl();
if (url != null && !url.trim().isEmpty()) {
    ARouter.getInstance().build(Uri.parse(url)).navigation();
}
Defensive patterns

Strategy: validation

Validate before calling

if (uri == null || uri.toString().trim().isEmpty()) {
    return; // cannot route
}

Type guard

public static boolean isValidUri(Uri u) { return u != null && !u.toString().trim().isEmpty(); }

Try / catch

try {
    ARouter.getInstance().build(uri).navigation();
} catch (HandlerException e) {
    Log.w(TAG, "Invalid deep-link uri", e);
}

Prevention

When it happens

Trigger: Calling ARouter.build((Uri) null), or forwarding a Uri parsed from an empty/blank string; getIntent().getData() returning null on a deep-link entry point and passing it straight through.

Common situations: Deep-link handlers that don't check getData() for null; webview or push payload URLs that are empty after trimming; URIs built with Uri.parse("").

Related errors


AI-assisted analysis of alibaba/ARouter@84f451d244 (2026-09-06). Data as JSON: /api/errors/bd8210423ba1923d. Report an issue: GitHub.