Tencent/WeKnora · error

chunk service is unavailable

Error message

chunk service is unavailable

What it means

Dependency guard: the chunk service handle is nil in this tool instance (wiring/initialization skipped or unavailable), so chunk lookups cannot be performed and the helper fails fast rather than nil-panicking.

Source

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

}

// 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(
		ctx, searchTargets, chunk.KnowledgeID, chunk.KnowledgeBaseID, knowledgeService,
	)
	if err != nil {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify service wiring/DI provides a chunk service to the tool
  2. Return a feature-unavailable signal to the caller
  3. Guard tool registration on required services being present
Defensive patterns

Strategy: type-guard

When it happens

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