{"record":{"id":"ff708f1bcea9a627","repo":"Tencent/WeKnora","slug":"chunk-service-is-unavailable","errorCode":null,"errorMessage":"chunk service is unavailable","messagePattern":"chunk service is unavailable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/scope_authorization.go","lineNumber":110,"sourceCode":"}\n\n// authorizeChunkInSearchTargets is the chunk/FAQ counterpart of\n// authorizeKnowledgeInSearchTargets. A chunk ID is accepted only after the\n// server resolves its owning document and validates that document against the\n// full KB/document/tag scope.\nfunc authorizeChunkInSearchTargets(\n\tctx context.Context,\n\tsearchTargets types.SearchTargets,\n\tchunkID string,\n\tchunkService interfaces.ChunkService,\n\tknowledgeService interfaces.KnowledgeService,\n) (*types.Chunk, error) {\n\tchunkID = strings.TrimSpace(chunkID)\n\tif chunkID == \"\" {\n\t\treturn nil, fmt.Errorf(\"chunk_id is required\")\n\t}\n\tif chunkService == nil {\n\t\treturn nil, fmt.Errorf(\"chunk service is unavailable\")\n\t}\n\tchunk, err := chunkService.GetChunkByIDOnly(ctx, chunkID)\n\tif err != nil || chunk == nil {\n\t\tif err == nil {\n\t\t\terr = fmt.Errorf(\"empty result\")\n\t\t}\n\t\treturn nil, fmt.Errorf(\"chunk %s not found: %w\", chunkID, err)\n\t}\n\tif !chunk.IsEnabled {\n\t\treturn nil, fmt.Errorf(\"chunk %s is disabled\", chunk.ID)\n\t}\n\tif !searchTargets.ContainsKB(chunk.KnowledgeBaseID) {\n\t\treturn nil, fmt.Errorf(\"knowledge base %s is not within the current Agent scope\", chunk.KnowledgeBaseID)\n\t}\n\tallowed, err := searchTargetsAllowKnowledgeID(\n\t\tctx, searchTargets, chunk.KnowledgeID, chunk.KnowledgeBaseID, knowledgeService,\n\t)\n\tif err != nil {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/scope_authorization.go#L92-L128","documentation":"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.","triggerScenarios":"Thrown at internal/agent/tools/scope_authorization.go:110 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify service wiring/DI provides a chunk service to the tool","Return a feature-unavailable signal to the caller","Guard tool registration on required services being present"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}