{"record":{"id":"c94f88b96b94a54e","repo":"Tencent/WeKnora","slug":"ego-graph-requires-a-center-slug","errorCode":null,"errorMessage":"ego graph requires a center slug","messagePattern":"ego graph requires a center slug","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/wiki_page.go","lineNumber":628,"sourceCode":"\tfor _, id := range req.FamiliarKnowledgeIDs {\n\t\tif id = strings.TrimSpace(id); id != \"\" {\n\t\t\tfamiliarSet[id] = struct{}{}\n\t\t}\n\t}\n\n\tpageBySlug := make(map[string]*types.WikiPage, len(pages))\n\tlinkCount := make(map[string]int, len(pages))\n\tfor _, p := range pages {\n\t\tpageBySlug[p.Slug] = p\n\t\tlinkCount[p.Slug] = len(p.InLinks) + len(p.OutLinks)\n\t}\n\n\t// Select the node slug set for the requested slice.\n\tvar selected map[string]struct{}\n\tswitch mode {\n\tcase types.WikiGraphModeEgo:\n\t\tif req.Center == \"\" {\n\t\t\treturn nil, errors.New(\"ego graph requires a center slug\")\n\t\t}\n\t\tif _, ok := pageBySlug[req.Center]; !ok {\n\t\t\treturn nil, fmt.Errorf(\"ego center slug %q not found\", req.Center)\n\t\t}\n\t\tdepth := req.Depth\n\t\tif depth < 1 {\n\t\t\tdepth = 1\n\t\t}\n\t\tselected = bfsEgoSlugs(pageBySlug, req.Center, depth, typeAllow, req.Limit)\n\tdefault:\n\t\t// overview: keep only type-allowed candidates, sort by link_count desc, cap.\n\t\tcandidates := make([]*types.WikiPage, 0, len(pages))\n\t\tfor _, p := range pages {\n\t\t\tif hasTypeFilter && !typeAllow[p.PageType] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcandidates = append(candidates, p)\n\t\t}","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/wiki_page.go#L610-L646","documentation":"Raised in computeGraphSubset when WikiGraphModeEgo is requested but req.Center is an empty slug — the ego graph slice is defined by a center node, so without one the request is invalid. Input guard before center-page existence is checked.","triggerScenarios":"Thrown at internal/application/service/wiki_page.go:628 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a center slug in the graph request when using ego mode","Use overview mode if no specific center node is intended"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}