Tencent/WeKnora · error
ego center slug %q not found
Error message
ego center slug %q not found
What it means
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.
Source
Thrown at internal/application/service/wiki_page.go:631
}
}
pageBySlug := make(map[string]*types.WikiPage, len(pages))
linkCount := make(map[string]int, len(pages))
for _, p := range pages {
pageBySlug[p.Slug] = p
linkCount[p.Slug] = len(p.InLinks) + len(p.OutLinks)
}
// Select the node slug set for the requested slice.
var selected map[string]struct{}
switch mode {
case types.WikiGraphModeEgo:
if req.Center == "" {
return nil, errors.New("ego graph requires a center slug")
}
if _, ok := pageBySlug[req.Center]; !ok {
return nil, fmt.Errorf("ego center slug %q not found", req.Center)
}
depth := req.Depth
if depth < 1 {
depth = 1
}
selected = bfsEgoSlugs(pageBySlug, req.Center, depth, typeAllow, req.Limit)
default:
// overview: keep only type-allowed candidates, sort by link_count desc, cap.
candidates := make([]*types.WikiPage, 0, len(pages))
for _, p := range pages {
if hasTypeFilter && !typeAllow[p.PageType] {
continue
}
candidates = append(candidates, p)
}
sort.SliceStable(candidates, func(i, j int) bool {
li := linkCount[candidates[i].Slug]
lj := linkCount[candidates[j].Slug]View on GitHub (pinned to 988cbb0330)
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.
Example fix
// before
req := types.WikiGraphRequest{Mode: types.WikiGraphModeEgo, Center: "My Page"}
// after
req := types.WikiGraphRequest{Mode: types.WikiGraphModeEgo, Center: "my-page"} // verified existing slug Defensive patterns
Strategy: validation
Validate before calling
page, err := pageSvc.GetBySlug(ctx, kbID, centerSlug)
if err != nil || page == nil {
return fmt.Errorf("cannot build ego graph: slug %q not in KB %s", centerSlug, kbID)
} Type guard
func hasValidCenter(slugs map[string]*types.WikiPage, center string) bool {
return center != "" && slugs[center] != nil
} Try / catch
graph, err := svc.GetGraph(ctx, kbID, req)
if err != nil && strings.Contains(err.Error(), "ego center slug") {
log.Warnf("center %q missing, falling back to overview", req.Center)
req.Mode = types.WikiGraphModeOverview
graph, err = svc.GetGraph(ctx, kbID, req)
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/41063dd32177d1cb.
Report an issue: GitHub.