{"record":{"id":"eac15c7012f71226","repo":"Tencent/WeKnora","slug":"knowledge-service-returned-an-empty-result","errorCode":null,"errorMessage":"knowledge service returned an empty result","messagePattern":"knowledge service returned an empty result","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/data_schema.go","lineNumber":73,"sourceCode":"\tvar input DataSchemaInput\n\tif err := json.Unmarshal(args, &input); err != nil {\n\t\treturn &types.ToolResult{\n\t\t\tSuccess: false,\n\t\t\tError:   fmt.Sprintf(\"Failed to parse input args: %v\", err),\n\t\t}, err\n\t}\n\n\t// Get knowledge to get TenantID (use IDOnly to support cross-tenant shared KB)\n\tvar knowledge *types.Knowledge\n\tvar err error\n\tif t.scopeEnforced {\n\t\tknowledge, err = authorizeKnowledgeInSearchTargets(ctx, t.searchTargets, input.KnowledgeID, t.knowledgeService)\n\t} else {\n\t\tknowledge, err = t.knowledgeService.GetKnowledgeByIDOnly(ctx, input.KnowledgeID)\n\t}\n\tif err != nil || knowledge == nil {\n\t\tif err == nil {\n\t\t\terr = fmt.Errorf(\"knowledge service returned an empty result\")\n\t\t}\n\t\treturn &types.ToolResult{\n\t\t\tSuccess: false,\n\t\t\tError:   fmt.Sprintf(\"Failed to get knowledge '%s': %v\", input.KnowledgeID, err),\n\t\t}, err\n\t}\n\n\t// Get chunks for the knowledge ID using ChunkRepository\n\t// We only need table summary and column chunks\n\tchunkTypes := t.targetChunkTypes\n\tpage := &types.Pagination{\n\t\tPage:     1,\n\t\tPageSize: 100, // Should be enough for schema chunks\n\t}\n\tenabled := true\n\n\tchunks, _, err := t.chunkRepo.ListPagedChunksByKnowledgeID(\n\t\tctx,","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/data_schema.go#L55-L91","documentation":"DataSchema tool's knowledge lookup returned a nil Knowledge without a transport error: the service found no record for the provided knowledge_id (or scope enforcement filtered it out), so schema extraction cannot proceed because there is no backing document.","triggerScenarios":"Thrown at internal/agent/tools/data_schema.go:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the knowledge_id passed in the tool args actually exists","Check whether scope enforcement (authorizeKnowledgeInSearchTargets) rejected the ID and widen scope if legitimate","Return a clearer 'knowledge not found' message distinguishing lookup failure from authorization failure"],"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"}