{"record":{"id":"89b5d7bb8b180a28","repo":"Tencent/WeKnora","slug":"all-document-retrievals-failed","errorCode":null,"errorMessage":"all document retrievals failed","messagePattern":"all document retrievals failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/get_document_info.go","lineNumber":237,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t\tresult := results[\"faq:\"+faqID]\n\t\tif result == nil {\n\t\t\terrors = append(errors, fmt.Sprintf(\"faq:%s: not found\", faqID))\n\t\t\tcontinue\n\t\t}\n\t\tif result.err != nil {\n\t\t\terrors = append(errors, fmt.Sprintf(\"faq:%s: %v\", faqID, result.err))\n\t\t} else if result.chunk != nil {\n\t\t\tsuccessDocs = append(successDocs, result)\n\t\t}\n\t}\n\n\tif len(successDocs) == 0 {\n\t\treturn &types.ToolResult{\n\t\t\tSuccess: false,\n\t\t\tError:   fmt.Sprintf(\"Failed to retrieve any document info. Errors: %v\", errors),\n\t\t}, fmt.Errorf(\"all document retrievals failed\")\n\t}\n\n\toutput := \"=== Document Info ===\\n\\n\"\n\toutput += fmt.Sprintf(\"Successfully retrieved %d / %d entries\\n\\n\", len(successDocs), requested)\n\n\tif len(errors) > 0 {\n\t\toutput += \"=== Partial Failures ===\\n\"\n\t\tfor _, errMsg := range errors {\n\t\t\toutput += fmt.Sprintf(\"  - %s\\n\", errMsg)\n\t\t}\n\t\toutput += \"\\n\"\n\t}\n\n\tformattedDocs := make([]map[string]interface{}, 0, len(successDocs))\n\tfor i, doc := range successDocs {\n\t\toutput += fmt.Sprintf(\"[Entry #%d]\\n\", i+1)\n\n\t\tif doc.chunk != nil {","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/get_document_info.go#L219-L255","documentation":"GetDocumentInfo aggregates document info lookups for multiple requested documents. If every single retrieval fails (successDocs is empty), the tool returns a failed ToolResult and this error. It is an aggregate-failure signal: at least one underlying doc lookup errored for all requested IDs.","triggerScenarios":"Calling the get_document_info tool where every requested document ID fails lookup — e.g. IDs not present in the document service, service outage, or permission denial for all documents.","commonSituations":"Agent passes stale/renamed document IDs; document store unavailable or misconfigured; tenant/permission scoping excludes all requested docs.","solutions":["Inspect the ToolResult.Error string (it embeds the per-document errors map) to see the underlying cause for each ID","Verify the document IDs exist via a list/search tool before calling get_document_info","Check document-service connectivity and configuration","Retry with a subset of IDs to isolate whether it is one bad ID or a service-wide issue"],"exampleFix":"// before\nresult, _ := getDocInfo.Execute(ctx, map[string]any{\"document_ids\": []string{\"doc-old-1\",\"doc-old-2\"}})\n// after\nlisted := searchTool.FindDocuments(ctx, \"invoice\") // confirm current IDs first\nresult, _ := getDocInfo.Execute(ctx, map[string]any{\"document_ids\": listed[:2]})","handlingStrategy":"validation","validationCode":"for _, id := range docIDs {\n    if strings.TrimSpace(id) == \"\" { return fmt.Errorf(\"empty document id in request\") }\n}\nif len(docIDs) == 0 { return errors.New(\"at least one document id required\") }","typeGuard":"func validDocIDs(ids []string) bool {\n    for _, id := range ids { if strings.TrimSpace(id) == \"\" { return false } }\n    return len(ids) > 0\n}","tryCatchPattern":"res, err := tool.Execute(ctx, input)\nif err != nil {\n    if strings.Contains(err.Error(), \"all document retrievals failed\") {\n        log.Printf(\"per-doc errors: %s\", res.Error) // embedded per-ID failures\n        return fallbackLookup(ctx, docIDs)\n    }\n    return err\n}","preventionTips":["Resolve document IDs via search/list tools instead of hardcoding them","Log the per-document error map embedded in ToolResult.Error","Check document-service health before large batch retrievals","Test with a single ID first when debugging"],"tags":["go","agent-tools","document-retrieval","multi-error"],"backgroundTag":"all-retrievals-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}