Tencent/WeKnora · error
knowledge_id is required
Error message
knowledge_id is required
What it means
authorizeKnowledgeInSearchTargets in internal/agent/tools/scope_authorization.go resolves and authorizes a knowledge-base item for a search. It throws this error when the knowledge_id parameter is empty or whitespace-only after strings.TrimSpace, because authorization cannot proceed without an identifier.
Source
Thrown at internal/agent/tools/scope_authorization.go:67
}
knowledgeIDs, tagIDs := searchTargetScope(target)
return target.Type == types.SearchTargetTypeKnowledgeBase &&
len(knowledgeIDs) == 0 && len(tagIDs) == 0
}
// authorizeKnowledgeInSearchTargets is the shared authorization boundary for
// every Agent tool that accepts a model-visible dN/knowledge_id. Handle
// decoding is necessary but never sufficient: the durable document must also
// belong to the server-owned search scope for this Agent execution.
func authorizeKnowledgeInSearchTargets(
ctx context.Context,
searchTargets types.SearchTargets,
knowledgeID string,
knowledgeService interfaces.KnowledgeService,
) (*types.Knowledge, error) {
knowledgeID = strings.TrimSpace(knowledgeID)
if knowledgeID == "" {
return nil, fmt.Errorf("knowledge_id is required")
}
if knowledgeService == nil {
return nil, fmt.Errorf("knowledge service is unavailable")
}
knowledge, err := knowledgeService.GetKnowledgeByIDOnly(ctx, knowledgeID)
if err != nil || knowledge == nil {
if err == nil {
err = fmt.Errorf("empty result")
}
return nil, fmt.Errorf("document %s not found: %w", knowledgeID, err)
}
if !searchTargets.ContainsKB(knowledge.KnowledgeBaseID) {
return nil, fmt.Errorf("knowledge base %s is not within the current Agent scope", knowledge.KnowledgeBaseID)
}
allowed, err := searchTargetsAllowKnowledgeID(
ctx, searchTargets, knowledge.ID, knowledge.KnowledgeBaseID, knowledgeService,
)
if err != nil {View on GitHub (pinned to 988cbb0330)
Solutions
- Pass a valid, non-empty knowledge_id in the tool call arguments.
- Trim and check the value before calling: strings.TrimSpace(knowledgeID) != "".
- Trace upstream where the ID is produced (config, DB record, prior tool result) to find why it is empty.
Example fix
// before
result, err := tool.Execute(ctx, map[string]any{"query": q})
// after
result, err := tool.Execute(ctx, map[string]any{"query": q, "knowledge_id": kbID}) // kbID must be non-empty Defensive patterns
Strategy: validation
Validate before calling
kbID := strings.TrimSpace(args["knowledge_id"])
if kbID == "" {
return fmt.Errorf("cannot search: knowledge_id is empty")
} Try / catch
knowledge, err := authorizeKnowledgeInSearchTargets(ctx, targets, kbID, svc)
if err != nil && strings.Contains(err.Error(), "knowledge_id is required") {
return nil, fmt.Errorf("tool call missing knowledge_id: %w", err)
} Prevention
- Validate required tool-call arguments (non-empty after trim) before invoking.
- Ensure the knowledge_id is resolved from a reliable source (config/DB) and logged when absent.
- Document knowledge_id as required in the tool schema so agents always supply it.
When it happens
Trigger: Calling Execute (or resolveAuthorizedSourceRefs) on the knowledge search tool without a knowledge_id field, or with a value of only spaces/tabs, or where an upstream mapping left the field unset.
Common situations: Agent omitted the optional-looking parameter in the tool-call JSON; a variable holding the ID was empty because lookup failed earlier; whitespace introduced when building the request string.
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
- model ID cannot be empty
- unknown credential field:
- member_limit must be >= 0
- cannot request upgrade to same or lower role
- E2B timeout must be at least one second
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/703c667974b5168d.
Report an issue: GitHub.