{"record":{"id":"3108b8b0ed3c4e48","repo":"alibaba/ARouter","slug":"extract-the-default-group-failed-there-s-nothing","errorCode":null,"errorMessage":"Extract the default group failed! There's nothing between 2 '/'!","messagePattern":"Extract the default group failed! There's nothing between 2 '/'!","errorType":"exception","errorClass":"HandlerException","httpStatus":null,"severity":"error","filePath":"arouter-api/src/main/java/com/alibaba/android/arouter/launcher/_ARouter.java","lineNumber":251,"sourceCode":"        } catch (HandlerException invalidPath) {\n            return false;\n        }\n\n        return LogisticsCenter.hasRoute(postcard);\n    }\n\n    /**\n     * Extract the default group from path.\n     */\n    private String extractGroup(String path) {\n        if (TextUtils.isEmpty(path) || !path.startsWith(\"/\")) {\n            throw new HandlerException(Consts.TAG + \"Extract the default group failed, the path must be start with '/' and contain more than 2 '/'!\");\n        }\n\n        try {\n            String defaultGroup = path.substring(1, path.indexOf(\"/\", 1));\n            if (TextUtils.isEmpty(defaultGroup)) {\n                throw new HandlerException(Consts.TAG + \"Extract the default group failed! There's nothing between 2 '/'!\");\n            } else {\n                return defaultGroup;\n            }\n        } catch (Exception e) {\n            logger.warning(Consts.TAG, \"Failed to extract default group! \" + e.getMessage());\n            return null;\n        }\n    }\n\n    static void afterInit() {\n        // Trigger interceptor init, use byName.\n        interceptorService = (InterceptorService) ARouter.getInstance().build(\"/arouter/service/interceptor\").navigation();\n    }\n\n    protected <T> T navigation(Class<? extends T> service) {\n        try {\n            Postcard postcard = LogisticsCenter.buildProvider(service.getName());\n","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/alibaba/ARouter/blob/84f451d244e3fb1d0e37801de1b9ee2af2f81d68/arouter-api/src/main/java/com/alibaba/android/arouter/launcher/_ARouter.java#L233-L269","documentation":"When the path starts with '/' but has no second '/' (or nothing between the two slashes), extractGroup cannot produce a group name. The code attempts substring extraction and throws HandlerException for the empty-group case; note the surrounding catch logs a warning and returns null for other parse failures, which then triggers the 'Parameter is invalid' error in build(path, group, ...).","triggerScenarios":"Calling build(\"/login\") — starts with '/' but no second segment — or build(\"//detail\") with nothing between the slashes.","commonSituations":"Paths registered without a group prefix; single-segment paths like \"/main\"; migrating from another router library that allowed single-segment paths.","solutions":["Use two-segment paths: '/group/name' (e.g. '/app/main' instead of '/main')","Re-register the @Route(path) annotations with a proper group segment","Add a path normalizer (PathReplaceService) that inserts a default group for single-segment paths","Check for accidental double slashes in configured paths"],"exampleFix":"// before\n@Route(path = \"/main\")            // no group segment\npublic class MainActivity ...\n// after\n@Route(path = \"/app/main\")        // group 'app', path 'main'\npublic class MainActivity ...","handlingStrategy":"validation","validationCode":"public static boolean hasGroupSegment(String path) {\n    if (path == null || !path.startsWith(\"/\")) return false;\n    int second = path.indexOf('/', 1);\n    return second > 1; // non-empty group between slashes\n}","typeGuard":null,"tryCatchPattern":"try {\n    ARouter.getInstance().build(path).navigation();\n} catch (HandlerException e) {\n    Log.w(TAG, \"Path missing group segment\", e);\n}","preventionTips":["Register every @Route with '/group/name', never single-segment paths","Add a PathReplaceService to map legacy single-segment paths","Grep CI for @Route(path = \"/x\") single-segment registrations"],"tags":["android","arouter","path-format","group"],"backgroundTag":"invalid-argument-format","analyzedSha":"84f451d244e3fb1d0e37801de1b9ee2af2f81d68","analyzedAt":"2026-09-06T13:30:41.084Z","contentChangedAt":"2026-09-06T13:30:41.084Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}