Tencent/WeKnora · warning
knowledge_base_id is required
Error message
knowledge_base_id is required
What it means
CreatePage requires the page to reference a knowledge base; when page.KnowledgeBaseID is empty the service returns this error. Without the KB association the page cannot be scoped, listed, or have its slug uniqueness enforced within the right namespace.
Source
Thrown at internal/application/service/wiki_page.go:78
return &wikiPageService{
repo: repo,
chunkRepo: chunkRepo,
kbService: kbService,
taskPendingRepo: taskPendingRepo,
redisClient: redisClient,
}
}
// CreatePage creates a new wiki page
func (s *wikiPageService) CreatePage(ctx context.Context, page *types.WikiPage) (*types.WikiPage, error) {
if page.ID == "" {
page.ID = uuid.New().String()
}
if page.Slug == "" {
return nil, errors.New("wiki page slug is required")
}
if page.KnowledgeBaseID == "" {
return nil, errors.New("knowledge_base_id is required")
}
if page.Status == "" {
page.Status = types.WikiPageStatusPublished
}
if page.Version == 0 {
page.Version = 1
}
page.LastEditSource = types.WikiEditSourceFromContext(ctx)
page.LastEditorID, _ = types.UserIDFromContext(ctx)
stripWikiPageInlineChunkCitations(page)
// Parse outbound links from content
page.OutLinks = s.parseOutLinks(page.Content)
if err := s.applyFolderToPage(ctx, page); err != nil {
return nil, err
}
normalizeWikiHierarchy(page)
View on GitHub (pinned to 988cbb0330)
Solutions
- Populate page.KnowledgeBaseID from the request/route context before calling CreatePage.
- Validate knowledge_base_id is present at the handler boundary and return 400 otherwise.
- Verify the JSON tag/field name used by request binding matches what clients send.
Example fix
// before
page := &types.WikiPage{Slug: slug, Title: req.Title}
// after
page := &types.WikiPage{Slug: slug, Title: req.Title, KnowledgeBaseID: kbIDFromRequest} Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(page.KnowledgeBaseID) == "" {
return httpError(400, "knowledge_base_id is required")
} Prevention
- Populate KnowledgeBaseID from route context in a shared handler helper.
- Mark knowledge_base_id as binding:"required" on request structs.
- Keep JSON tag names in sync with client payloads after refactors.
When it happens
Trigger: Calling CreatePage with page.KnowledgeBaseID == "" — e.g. the request did not include the KB id, or a route param failed to bind into the WikiPage struct.
Common situations: Client omits knowledge_base_id in the create payload; endpoint refactor renamed the field so binding now leaves it empty; scripts creating pages across KBs forgetting the association.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- wiki page slug is required
- cannot revert to the current version
- wiki graph request is required
- slug is required
- cannot choose a knowledge base for new wiki page %s from %d
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/ff03de2c0bc7701c.
Report an issue: GitHub.