{"record":{"id":"6723726e227d61cb","repo":"Tencent/WeKnora","slug":"chunk-id-is-required","errorCode":null,"errorMessage":"chunk_id is required","messagePattern":"chunk_id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/scope_authorization.go","lineNumber":107,"sourceCode":"\t\treturn nil, fmt.Errorf(\"document %s is not within the current @mention scope\", knowledge.ID)\n\t}\n\treturn knowledge, nil\n}\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(","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/scope_authorization.go#L89-L125","documentation":"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.","triggerScenarios":"Thrown at internal/agent/tools/scope_authorization.go:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply a non-empty chunk_id","Trim/validate caller input before invoking chunk-based tools"],"exampleFix":null,"handlingStrategy":"validation","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"}