Tencent/WeKnora · error
failed to validate chunk scope: %w
Error message
failed to validate chunk scope: %w
What it means
The fine-grained document-scope check for the chunk's owning document errored (service failure inside searchTargetsAllowKnowledgeID), so authorization cannot be decided and fails closed with a wrapped validation error.
Source
Thrown at internal/agent/tools/scope_authorization.go:129
}
chunk, err := chunkService.GetChunkByIDOnly(ctx, chunkID)
if err != nil || chunk == nil {
if err == nil {
err = fmt.Errorf("empty result")
}
return nil, fmt.Errorf("chunk %s not found: %w", chunkID, err)
}
if !chunk.IsEnabled {
return nil, fmt.Errorf("chunk %s is disabled", chunk.ID)
}
if !searchTargets.ContainsKB(chunk.KnowledgeBaseID) {
return nil, fmt.Errorf("knowledge base %s is not within the current Agent scope", chunk.KnowledgeBaseID)
}
allowed, err := searchTargetsAllowKnowledgeID(
ctx, searchTargets, chunk.KnowledgeID, chunk.KnowledgeBaseID, knowledgeService,
)
if err != nil {
return nil, fmt.Errorf("failed to validate chunk scope: %w", err)
}
if !allowed {
return nil, fmt.Errorf("chunk %s is not within the current @mention scope", chunk.ID)
}
return chunk, nil
}
// validateKnowledgeBaseIDsInSearchTargets rejects hallucinated, stale, or
// out-of-scope bN values after the model-context registry resolves them.
func validateKnowledgeBaseIDsInSearchTargets(searchTargets types.SearchTargets, kbIDs []string) error {
for _, kbID := range dedupNonEmptyStrings(kbIDs) {
if !searchTargets.ContainsKB(kbID) {
return fmt.Errorf("knowledge base %s is not within the current Agent scope", kbID)
}
}
return nil
}
View on GitHub (pinned to 988cbb0330)
Solutions
- Inspect the chained inner error for the failing service call
- Check knowledge service availability
- Retry transient failures during chunk scope validation
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/agent/tools/scope_authorization.go:129 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/ca6bf3bd977762d0.
Report an issue: GitHub.