Tencent/WeKnora · error
chunk %s not found: %w
Error message
chunk %s not found: %w
What it means
Chunk authorization lookup failed: GetChunkByIDOnly returned an error or an empty result (inner 'empty result' sentinel if nil,nil), so the chunk cannot be resolved for scope checks and access is denied with a not-found error.
Source
Thrown at internal/agent/tools/scope_authorization.go:117
ctx context.Context,
searchTargets types.SearchTargets,
chunkID string,
chunkService interfaces.ChunkService,
knowledgeService interfaces.KnowledgeService,
) (*types.Chunk, error) {
chunkID = strings.TrimSpace(chunkID)
if chunkID == "" {
return nil, fmt.Errorf("chunk_id is required")
}
if chunkService == nil {
return nil, fmt.Errorf("chunk service is unavailable")
}
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
}View on GitHub (pinned to 988cbb0330)
Solutions
- Confirm the chunk ID exists
- Check chunk service/storage health for the inner error
- Handle uniformly as not-found to avoid leaking existence
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/agent/tools/scope_authorization.go:117 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/5bce1a8cf39bcbab.
Report an issue: GitHub.