{"record":{"id":"a9a480e55ec0ce1c","repo":"Tencent/WeKnora","slug":"missing-id-parameter","errorCode":null,"errorMessage":"missing id parameter","messagePattern":"missing id parameter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/list_knowledge_chunks.go","lineNumber":117,"sourceCode":"\t\t\tSuccess: false,\n\t\t\tError:   fmt.Sprintf(\"Failed to parse args: %v\", err),\n\t\t}, err\n\t}\n\n\tchunkID := strings.TrimSpace(input.FAQID)\n\tif chunkID == \"\" {\n\t\tchunkID = strings.TrimSpace(input.ChunkID)\n\t}\n\tif chunkID != \"\" {\n\t\treturn t.executeByChunkID(ctx, chunkID)\n\t}\n\n\tknowledgeID := strings.TrimSpace(input.KnowledgeID)\n\tif knowledgeID == \"\" {\n\t\treturn &types.ToolResult{\n\t\t\tSuccess: false,\n\t\t\tError:   \"one of faq_id, chunk_id, or knowledge_id is required\",\n\t\t}, fmt.Errorf(\"missing id parameter\")\n\t}\n\n\tknowledge, err := authorizeKnowledgeInSearchTargets(ctx, t.searchTargets, knowledgeID, t.knowledgeService)\n\tif err != nil {\n\t\treturn &types.ToolResult{\n\t\t\tSuccess: false,\n\t\t\tError:   fmt.Sprintf(\"Knowledge is not accessible: %v\", err),\n\t\t}, err\n\t}\n\n\t// Use the knowledge's actual tenant_id for chunk query (supports cross-tenant shared KB)\n\teffectiveTenantID := knowledge.TenantID\n\n\tchunkLimit := 20\n\tif input.Limit > 0 {\n\t\tchunkLimit = input.Limit\n\t}\n\toffset := 0","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/list_knowledge_chunks.go#L99-L135","documentation":"ListKnowledgeChunks.Execute needs a knowledge identifier to look up chunks. After trimming, if KnowledgeID (any of faq_id/chunk_id/knowledge_id forms) is empty it returns this error. It is a fail-fast validation that no ID was supplied at all — distinct from authorization or not-found errors.","triggerScenarios":"Calling list_knowledge_chunks with knowledge_id absent, empty string, or only whitespace.","commonSituations":"Agent omits the id field in the tool call; caller passes a variable that was never set; key-name mismatch in the params map leaves the field blank.","solutions":["Supply a non-empty knowledge_id (or faq_id/chunk_id) in the tool input","Trim and validate the ID in the caller before invoking","Fetch a valid knowledge ID from a search/list tool if none is known"],"exampleFix":"// before\nExecute(ctx, map[string]any{\"knowledge_id\": \"   \"})\n// after\nid := strings.TrimSpace(kbID)\nif id == \"\" { return errors.New(\"knowledge_id required\") }\nExecute(ctx, map[string]any{\"knowledge_id\": id})","handlingStrategy":"validation","validationCode":"id := strings.TrimSpace(input[\"knowledge_id\"])\nif id == \"\" { return errors.New(\"one of faq_id, chunk_id, or knowledge_id is required\") }","typeGuard":"func hasKnowledgeID(input map[string]any) bool {\n    id, ok := input[\"knowledge_id\"].(string)\n    return ok && strings.TrimSpace(id) != \"\"\n}","tryCatchPattern":"res, err := tool.Execute(ctx, input)\nif err != nil && strings.Contains(err.Error(), \"missing id parameter\") {\n    return res, nil // ToolResult.Error already explains required fields\n}","preventionTips":["Pass an ID obtained from a prior search/list tool call","Trim whitespace from IDs before invoking","Instruct agents that list_knowledge_chunks always needs an id","Distinguish this validation error from not-found/authorization errors when handling"],"tags":["go","agent-tools","input-validation","missing-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}