{"record":{"id":"086f6422dd742ba5","repo":"Tencent/WeKnora","slug":"document-s-is-not-within-the-current-mention-sco","errorCode":null,"errorMessage":"document %s is not within the current @mention scope","messagePattern":"document (.+?) is not within the current @mention scope","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/scope_authorization.go","lineNumber":89,"sourceCode":"\t}\n\tknowledge, err := knowledgeService.GetKnowledgeByIDOnly(ctx, knowledgeID)\n\tif err != nil || knowledge == nil {\n\t\tif err == nil {\n\t\t\terr = fmt.Errorf(\"empty result\")\n\t\t}\n\t\treturn nil, fmt.Errorf(\"document %s not found: %w\", knowledgeID, err)\n\t}\n\tif !searchTargets.ContainsKB(knowledge.KnowledgeBaseID) {\n\t\treturn nil, fmt.Errorf(\"knowledge base %s is not within the current Agent scope\", knowledge.KnowledgeBaseID)\n\t}\n\tallowed, err := searchTargetsAllowKnowledgeID(\n\t\tctx, searchTargets, knowledge.ID, knowledge.KnowledgeBaseID, knowledgeService,\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to validate document scope: %w\", err)\n\t}\n\tif !allowed {\n\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\")","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/scope_authorization.go#L71-L107","documentation":"Document-level scope rejection: KB containment passed but the document ID is not among the explicitly @mentioned/allowed document IDs for this execution, so the fine-grained mention scope denies access even though the KB itself is in scope.","triggerScenarios":"Thrown at internal/agent/tools/scope_authorization.go:89 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include the document in the @mention set or allowed document list","Verify the mention scope resolution produced the expected IDs","Request access through scope configuration rather than bypassing the check"],"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"}