{"record":{"id":"41063dd32177d1cb","repo":"Tencent/WeKnora","slug":"ego-center-slug-q-not-found","errorCode":null,"errorMessage":"ego center slug %q not found","messagePattern":"ego center slug %q not found","errorType":"validation","errorClass":null,"httpStatus":404,"severity":"error","filePath":"internal/application/service/wiki_page.go","lineNumber":631,"sourceCode":"\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}\n\t\tsort.SliceStable(candidates, func(i, j int) bool {\n\t\t\tli := linkCount[candidates[i].Slug]\n\t\t\tlj := linkCount[candidates[j].Slug]","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/wiki_page.go#L613-L649","documentation":"In ego-graph mode, computeGraphSubset requires req.Center to name an existing page slug. If the slug is empty it errors differently; if the slug is non-empty but no page matches, it returns 'ego center slug %q not found'. The graph cannot be built without a valid center node.","triggerScenarios":"Calling GetGraph with mode=ego and a Center slug that does not exist in the knowledge base (typo, deleted page, wrong KB, or slug casing/normalization mismatch).","commonSituations":"Page was renamed or deleted after the client cached the slug; client sends a page title or URL path instead of the slug; requesting across the wrong knowledge base ID; case-sensitive slug comparison vs normalized display names.","solutions":["Resolve the page slug via the index/list API and confirm it exists in the target KB before requesting an ego graph.","Check for typos, trailing whitespace, or case mismatches in the Center field.","Verify the page was not deleted or renamed; re-fetch current slugs.","Fall back to overview graph mode when the center is unknown."],"exampleFix":"// before\nreq := types.WikiGraphRequest{Mode: types.WikiGraphModeEgo, Center: \"My Page\"}\n// after\nreq := types.WikiGraphRequest{Mode: types.WikiGraphModeEgo, Center: \"my-page\"} // verified existing slug","handlingStrategy":"validation","validationCode":"page, err := pageSvc.GetBySlug(ctx, kbID, centerSlug)\nif err != nil || page == nil {\n    return fmt.Errorf(\"cannot build ego graph: slug %q not in KB %s\", centerSlug, kbID)\n}","typeGuard":"func hasValidCenter(slugs map[string]*types.WikiPage, center string) bool {\n    return center != \"\" && slugs[center] != nil\n}","tryCatchPattern":"graph, err := svc.GetGraph(ctx, kbID, req)\nif err != nil && strings.Contains(err.Error(), \"ego center slug\") {\n    log.Warnf(\"center %q missing, falling back to overview\", req.Center)\n    req.Mode = types.WikiGraphModeOverview\n    graph, err = svc.GetGraph(ctx, kbID, req)\n}","preventionTips":["Resolve slugs from the index API immediately before graph calls; never cache across renames/deletes","Trim and lowercase-normalize slugs client-side to match service normalization","Verify the KB ID matches the one the slug was obtained from","Fall back to overview mode when the center cannot be resolved"],"tags":["graph","slug-not-found","validation"],"backgroundTag":"resource-slug-not-found","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}