{"record":{"id":"3a03d28e5588fb34","repo":"locustio/locust","slug":"collection-name-must-be-provided-for-qdrantuser","errorCode":null,"errorMessage":"'collection_name' must be provided for QdrantUser","messagePattern":"'collection_name' must be provided for QdrantUser","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"locust/contrib/qdrant.py","lineNumber":171,"sourceCode":"    **collection_kwargs\n        Additional keyword arguments forwarded to ``create_collection``.\n    \"\"\"\n\n    abstract = True\n\n    url: str = \"http://localhost:6333\"\n    api_key: str | None = None\n    collection_name: str | None = None\n    timeout: int = 60\n    vectors_config: VectorParams | None = None\n    client_kwargs: dict | None = None\n    collection_kwargs: dict | None = None\n\n    def __init__(self, environment):\n        super().__init__(environment)\n\n        if self.collection_name is None:\n            raise ValueError(\"'collection_name' must be provided for QdrantUser\")\n\n        self.client_type = \"qdrant\"\n        self.client = QdrantLocustClient(\n            url=self.url,\n            api_key=self.api_key,\n            collection_name=self.collection_name,\n            timeout=self.timeout,\n            **(self.client_kwargs or {}),\n        )\n        if self.vectors_config is not None:\n            self.client.create_collection(vectors_config=self.vectors_config, **(self.collection_kwargs or {}))\n\n    @staticmethod\n    def _fire_event(request_type: str, name: str, result: dict[str, Any]):\n        \"\"\"Emit a Locust request event from a Qdrant client result dict.\"\"\"\n        response_time = int(result.get(\"response_time\", 0))\n        events.request.fire(\n            request_type=f\"{request_type}\",","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/contrib/qdrant.py#L153-L189","documentation":"QdrantUser requires a target collection name to operate on. The constructor checks `self.collection_name` immediately after delegating to super().__init__, and raises ValueError when it is None because the client cannot be constructed without a collection.","triggerScenarios":"Defining a QdrantUser subclass without setting `collection_name` as a class attribute; setting it to None explicitly; instantiating QdrantUser programmatically without the attribute.","commonSituations":"Copy-pasting a QdrantUser example and forgetting to fill in the collection name; renaming config keys so `collection_name` no longer maps to the class attribute; building users dynamically from config where the key is missing.","solutions":["Add `collection_name = \"your-collection\"` as a class attribute on your QdrantUser subclass","If loading from config/env, assign the value in the class body or before Environment creates user instances","Verify the attribute is not accidentally overridden to None in a subclass"],"exampleFix":"// before\nclass MyUser(QdrantUser):\n    url = \"http://localhost:6333\"\n// after\nclass MyUser(QdrantUser):\n    url = \"http://localhost:6333\"\n    collection_name = \"my_collection\"","handlingStrategy":"validation","validationCode":"class MyUser(QdrantUser):\n    collection_name = os.environ[\"QDRANT_COLLECTION\"]\n\nassert MyUser.collection_name, \"collection_name must be set\"","typeGuard":"def has_collection(user) -> bool:\n    return getattr(user, \"collection_name\", None) is not None","tryCatchPattern":"try:\n    user = MyUser(environment)\nexcept ValueError as e:\n    if \"collection_name\" in str(e):\n        raise RuntimeError(\"Set collection_name on your QdrantUser subclass\") from e\n    raise","preventionTips":["Always define collection_name in the class body of QdrantUser subclasses","Load it from env/config with a fail-fast default (KeyError over silent None)","Add a unit test that instantiates each user class"],"tags":["qdrant","configuration","missing-attribute"],"backgroundTag":"missing-required-config","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}