{"record":{"id":"4987fa4e100e8471","repo":"locustio/locust","slug":"ground-truth-length-is-less-than-limit-len-groun","errorCode":null,"errorMessage":"Ground truth length is less than limit: {len(ground_truth)} < {limit}","messagePattern":"Ground truth length is less than limit: (.+?) < (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"locust/contrib/milvus.py","lineNumber":218,"sourceCode":"    def get_recall(search_results, ground_truth, limit=None):\n        \"\"\"Calculate recall for V2 client search results.\"\"\"\n        try:\n            # Extract IDs from V2 search results\n            retrieved_ids = []\n            if isinstance(search_results, list) and len(search_results) > 0:\n                # search_results[0] contains the search results for the first query\n                for hit in search_results[0] if isinstance(search_results[0], list) else search_results:\n                    if isinstance(hit, dict) and \"id\" in hit:\n                        retrieved_ids.append(hit[\"id\"])\n                    elif hasattr(hit, \"get\"):\n                        retrieved_ids.append(hit.get(\"id\"))\n\n            # Apply limit if specified\n            if limit is None:\n                limit = len(retrieved_ids)\n\n            if len(ground_truth) < limit:\n                raise ValueError(f\"Ground truth length is less than limit: {len(ground_truth)} < {limit}\")\n\n            # Calculate recall\n            ground_truth_set = set(ground_truth[:limit])\n            retrieved_set = set(retrieved_ids)\n            intersect = len(ground_truth_set.intersection(retrieved_set))\n            return intersect / len(ground_truth_set)\n\n        except Exception:\n            return 0.0\n\n    def query(self, filter, output_fields=None):\n        if output_fields is None:\n            output_fields = [\"id\"]\n\n        start = time.time()\n        try:\n            result = self.client.query(\n                collection_name=self.collection_name,","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/contrib/milvus.py#L200-L236","documentation":"MilvusUser's recall calculation in get_recall raises ValueError when the ground-truth ID list is shorter than the requested limit, because slicing ground_truth[:limit] would produce a misleading (too small) denominator for recall. It is a guard against computing recall with insufficient ground truth data.","triggerScenarios":"Calling search(...) (which calls get_recall) with ground_truth containing fewer IDs than the specified limit parameter.","commonSituations":"Test datasets with fewer known-relevant results than the top-k limit requested in the search; misconfigured limit values in benchmark locustfiles; ground truth generated from a smaller corpus than the search collection.","solutions":["Reduce the limit parameter to at most len(ground_truth)","Provide more ground truth IDs so its length >= limit","Pass limit=None so it defaults to len(retrieved_ids) and validate ground truth separately"],"exampleFix":"// before\nrecall = get_recall(ground_truth=[\"1\", \"2\"], retrieved_ids=ids, limit=10)\n// after\nlimit = min(10, len(ground_truth))\nrecall = get_recall(ground_truth=ground_truth, retrieved_ids=ids, limit=limit)","handlingStrategy":"validation","validationCode":"def validate_recall_inputs(ground_truth, retrieved_ids, limit):\n    limit = len(retrieved_ids) if limit is None else limit\n    if len(ground_truth) < limit:\n        limit = len(ground_truth)  # or raise with a clear message\n    return limit","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure ground truth data covers at least the top-k limit requested","Clamp limit to min(limit, len(ground_truth)) before searching","Generate ground truth from the same corpus size as the searched collection"],"tags":["python","milvus","vector-search","valueerror"],"backgroundTag":"recall-computation-invalid","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}