alibaba/ARouter · error · HandlerException
Extract the default group failed, the path must be start wit
Error message
Extract the default group failed, the path must be start with '/' and contain more than 2 '/'!
What it means
extractGroup derives the route group (the segment between the first and second '/') from a path. ARouter throws HandlerException when the path is empty or does not start with '/', because the documented path convention '/group/xxx' cannot be parsed.
Source
Thrown at arouter-api/src/main/java/com/alibaba/android/arouter/launcher/_ARouter.java:245
* Check route availability without navigating to the destination.
*/
protected boolean hasRoute(String path) {
final Postcard postcard;
try {
postcard = build(path);
} catch (HandlerException invalidPath) {
return false;
}
return LogisticsCenter.hasRoute(postcard);
}
/**
* Extract the default group from path.
*/
private String extractGroup(String path) {
if (TextUtils.isEmpty(path) || !path.startsWith("/")) {
throw new HandlerException(Consts.TAG + "Extract the default group failed, the path must be start with '/' and contain more than 2 '/'!");
}
try {
String defaultGroup = path.substring(1, path.indexOf("/", 1));
if (TextUtils.isEmpty(defaultGroup)) {
throw new HandlerException(Consts.TAG + "Extract the default group failed! There's nothing between 2 '/'!");
} else {
return defaultGroup;
}
} catch (Exception e) {
logger.warning(Consts.TAG, "Failed to extract default group! " + e.getMessage());
return null;
}
}
static void afterInit() {
// Trigger interceptor init, use byName.
interceptorService = (InterceptorService) ARouter.getInstance().build("/arouter/service/interceptor").navigation();View on GitHub (pinned to 84f451d244)
Solutions
- Ensure every route path starts with '/' and contains at least two slashes: '/group/path'
- Normalize external input before building, e.g. prepend '/' when missing
- Register routes with the same convention used at lookup time
- Prefer the two-segment form and validate with a regex ^/[A-Za-z0-9_]+/.+
Example fix
// before
ARouter.getInstance().build("user/login").navigation(); // HandlerException
// after
String path = "user/login";
if (!path.startsWith("/")) path = "/" + path;
ARouter.getInstance().build(path).navigation(); Defensive patterns
Strategy: validation
Validate before calling
private static final Pattern ROUTE = Pattern.compile("^/[A-Za-z0-9_]+/.+");
public static boolean isValidRoutePath(String p) {
return p != null && ROUTE.matcher(p).matches();
} Try / catch
try {
ARouter.getInstance().build(path).navigation();
} catch (HandlerException e) {
Log.w(TAG, "Path must look like /group/xxx", e);
} Prevention
- Enforce the '/group/segment' convention in code review and CI
- Normalize external inputs to add the leading slash
- Store route constants centrally with the full two-segment path
When it happens
Trigger: Calling build("user/login") (missing leading slash), build(""), or hasRoute with such a path; passing a full URI string ('http://...') where a path is expected.
Common situations: Routes stored without the leading slash in config files; users passing package/class names instead of route paths; paths generated by concatenation losing the '/'; deep-link URL host+path mixed up.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Extract the default group failed! There's nothing between 2
- ARouter::Init::Invoke init(context) first!
- ARouterCore::Init::Invoke init(context) first!
- Parameter is invalid!
- Parameter invalid!
AI-assisted analysis of alibaba/ARouter@84f451d244 (2026-09-06).
Data as JSON: /api/errors/856aa515ef1bded6.
Report an issue: GitHub.