Tencent/WeKnora · error

chunk_id is required

Error message

chunk_id is required

What it means

Validation guard at the top of authorizeChunkInSearchTargets: the chunkID parameter (after strings.TrimSpace) is empty, so there is no chunk to authorize. It fires when a tool call or caller passes a blank/whitespace chunk_id, before any service lookup or scope checks happen.

Source

Thrown at internal/agent/tools/scope_authorization.go:107

		return nil, fmt.Errorf("document %s is not within the current @mention scope", knowledge.ID)
	}
	return knowledge, nil
}

// authorizeChunkInSearchTargets is the chunk/FAQ counterpart of
// authorizeKnowledgeInSearchTargets. A chunk ID is accepted only after the
// server resolves its owning document and validates that document against the
// full KB/document/tag scope.
func authorizeChunkInSearchTargets(
	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(

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Supply a non-empty chunk_id
  2. Trim/validate caller input before invoking chunk-based tools
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/agent/tools/scope_authorization.go:107 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/6723726e227d61cb. Report an issue: GitHub.