{"record":{"id":"48d677631673c916","repo":"locustio/locust","slug":"collection-name-must-be-provided-for-milvususer","errorCode":null,"errorMessage":"'collection_name' must be provided for MilvusUser","messagePattern":"'collection_name' must be provided for MilvusUser","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"locust/contrib/milvus.py","lineNumber":310,"sourceCode":"\n    def __init__(\n        self,\n        environment,\n        uri: str = \"http://localhost:19530\",\n        token: str = \"root:Milvus\",\n        collection_name: str = \"test_collection\",\n        db_name: str = \"default\",\n        timeout: int = 60,\n        schema: CollectionSchema | None = None,\n        index_params: IndexParams | None = None,\n        **kwargs,  # enable_dynamic_field, num_shards, consistency_level etc. ref: https://milvus.io/api-reference/pymilvus/v2.6.x/MilvusClient/Collections/create_collection.md\n    ):\n        super().__init__(environment)\n\n        if uri is None:\n            raise ValueError(\"'uri' must be provided for MilvusUser\")\n        if collection_name is None:\n            raise ValueError(\"'collection_name' must be provided for MilvusUser\")\n\n        self.client_type = \"milvus\"\n        self.client = MilvusV2Client(\n            uri=uri,\n            token=token,\n            collection_name=collection_name,\n            db_name=db_name,\n            timeout=timeout,\n        )\n        if schema is not None:\n            self.client.create_collection(schema=schema, index_params=index_params, **kwargs)\n\n    @staticmethod\n    def _fire_event(request_type: str, name: str, result: dict[str, Any]):\n        \"\"\"Emit a Locust request event from a Milvus client result dict.\"\"\"\n        response_time = int(result.get(\"response_time\", 0))\n        events.request.fire(\n            request_type=f\"{request_type}\",","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/contrib/milvus.py#L292-L328","documentation":"MilvusUser.__init__ raises ValueError when collection_name is None because both the pymilvus client operations and the benchmark logic need a target collection. It fails fast before constructing the MilvusV2Client.","triggerScenarios":"Instantiating MilvusUser without collection_name=..., or with collection_name explicitly None.","commonSituations":"Custom User subclasses not forwarding collection_name; collection created outside the locustfile and its name not wired into the test config; copy-pasted locustfile missing the parameter.","solutions":["Pass collection_name=... to MilvusUser.__init__","Load the collection name from an environment variable or config file","Verify your subclass forwards the argument to super().__init__"],"exampleFix":"// before\nsuper().__init__(environment, uri=uri)\n// after\nsuper().__init__(environment, uri=uri, collection_name=os.environ[\"MILVUS_COLLECTION\"])","handlingStrategy":"validation","validationCode":"import os\ncollection = os.environ.get(\"MILVUS_COLLECTION\")\nassert collection, \"MILVUS_COLLECTION env var must be set for MilvusUser\"\n# then: super().__init__(environment, uri=..., collection_name=collection)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass collection_name explicitly in every MilvusUser subclass","Use a shared config module for Milvus connection parameters","Smoke-test user instantiation before running a full load test"],"tags":["python","milvus","configuration","valueerror"],"backgroundTag":"missing-required-parameter","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}