{"record":{"id":"e4d1bffed41996bd","repo":"ipfs/kubo","slug":"dependency-loop-creating-router-with-name-q","errorCode":null,"errorMessage":"dependency loop creating router with name %q","messagePattern":"dependency loop creating router with name %q","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"routing/delegated.go","lineNumber":107,"sourceCode":"\treturn finalRouter, nil\n}\n\nfunc parse(visited map[string]bool,\n\tcreatedRouters map[string]routing.Routing,\n\trouterName string,\n\troutersCfg config.Routers,\n\textraDHT *ExtraDHTParams,\n\textraHTTP *ExtraHTTPParams,\n) (routing.Routing, error) {\n\t// check if we already created it\n\tr, ok := createdRouters[routerName]\n\tif ok {\n\t\treturn r, nil\n\t}\n\n\t// check if we are in a dep loop\n\tif visited[routerName] {\n\t\treturn nil, fmt.Errorf(\"dependency loop creating router with name %q\", routerName)\n\t}\n\n\t// set node as visited\n\tvisited[routerName] = true\n\n\tcfg, ok := routersCfg[routerName]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"config for router with name %q not found\", routerName)\n\t}\n\n\tvar router routing.Routing\n\tvar err error\n\tswitch cfg.Type {\n\tcase config.RouterTypeHTTP:\n\t\trouter, err = httpRoutingFromConfig(cfg.Router, extraHTTP)\n\tcase config.RouterTypeDHT:\n\t\trouter, err = dhtRoutingFromConfig(cfg.Router, extraDHT)\n\tcase config.RouterTypeParallel:","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/routing/delegated.go#L89-L125","documentation":"While recursively constructing the routing stack from the Routers config, a router (directly or through its SubRouters/Refs) depends on itself: the config's router dependency graph contains a cycle, so no valid construction order exists.","triggerScenarios":"Thrown at routing/delegated.go:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the Routers section and break the cycle (a router cannot reference itself via Refs/SubRouters, directly or indirectly)","Redraw the intended dependency order and encode it as separate composable routers","Reference: docs/config.md Routers section"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}