{"record":{"id":"50b4185c0a42a14e","repo":"locustio/locust","slug":"uri-must-be-provided-for-milvususer","errorCode":null,"errorMessage":"'uri' must be provided for MilvusUser","messagePattern":"'uri' must be provided for MilvusUser","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"locust/contrib/milvus.py","lineNumber":308,"sourceCode":"\n    abstract = True\n\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))","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/contrib/milvus.py#L290-L326","documentation":"MilvusUser.__init__ requires a Milvus server URI and raises ValueError immediately when uri is None, since the underlying pymilvus MilvusV2Client cannot connect without it. This fail-fast validation happens before any network activity.","triggerScenarios":"Instantiating MilvusUser (directly or as a base class of a custom user) without passing uri=..., or with uri explicitly None.","commonSituations":"Subclassing MilvusUser and overriding __init__ without forwarding uri; forgetting to load the URI from an environment variable or config; running the locustfile with missing CLI/config values.","solutions":["Pass uri=... to MilvusUser.__init__ (e.g. http://localhost:19530)","Load the URI from an environment variable and pass it through","Check that your custom User subclass forwards **kwargs/uri to super().__init__"],"exampleFix":"// before\nclass MilvusLoadUser(MilvusUser):\n    def __init__(self, environment):\n        super().__init__(environment)\n// after\nclass MilvusLoadUser(MilvusUser):\n    def __init__(self, environment):\n        super().__init__(environment, uri=os.environ[\"MILVUS_URI\"], collection_name=\"demo\")","handlingStrategy":"validation","validationCode":"import os\nuri = os.environ.get(\"MILVUS_URI\")\nassert uri, \"MILVUS_URI env var must be set for MilvusUser\"\n# then: super().__init__(environment, uri=uri, collection_name=...)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wire required params (uri, collection_name) from env vars or config with early asserts","Never override MilvusUser.__init__ without forwarding uri to super()","Validate config at locustfile module load time"],"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"}