{"record":{"id":"490df9d79c5bafc6","repo":"crewAIInc/crewAI","slug":"weaviate-url-or-weaviate-api-key-is-not-set","errorCode":null,"errorMessage":"WEAVIATE_URL or WEAVIATE_API_KEY is not set","messagePattern":"WEAVIATE_URL or WEAVIATE_API_KEY is not set","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/weaviate_tool/vector_search.py","lineNumber":113,"sourceCode":"        else:\n            if click.confirm(\n                \"You are missing the 'weaviate-client' package. Would you like to install it?\"\n            ):\n                subprocess.run([\"uv\", \"pip\", \"install\", \"weaviate-client\"], check=True)  # noqa: S607\n\n            else:\n                raise ImportError(\n                    \"You are missing the 'weaviate-client' package. Would you like to install it?\"\n                )\n\n    def _run(self, query: str) -> str:\n        if not WEAVIATE_AVAILABLE:\n            raise ImportError(\n                \"You are missing the 'weaviate-client' package. Would you like to install it?\"\n            )\n\n        if not self.weaviate_cluster_url or not self.weaviate_api_key:\n            raise ValueError(\"WEAVIATE_URL or WEAVIATE_API_KEY is not set\")\n\n        client = weaviate.connect_to_weaviate_cloud(\n            cluster_url=self.weaviate_cluster_url,\n            auth_credentials=Auth.api_key(self.weaviate_api_key),\n            headers=self.headers,\n        )\n        internal_docs = client.collections.get(self.collection_name)\n\n        if not internal_docs:\n            internal_docs = client.collections.create(\n                name=self.collection_name,\n                vectorizer_config=self.vectorizer,\n                generative_config=self.generative_model,\n            )\n\n        response = internal_docs.query.hybrid(\n            query=query, limit=self.limit, alpha=self.alpha\n        )","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/weaviate_tool/vector_search.py#L95-L131","documentation":"WeaviateVectorSearchTool._run requires both a cluster URL and an API key to call weaviate.connect_to_weaviate_cloud. If either weaviate_cluster_url or weaviate_api_key is empty/None at run time, it raises ValueError before attempting the connection.","triggerScenarios":"Calling tool.run(query) after constructing the tool with an empty string, None, or missing weaviate_cluster_url/weaviate_api_key (they are declared required Fields, but defaults or empty strings can still slip through depending on construction path).","commonSituations":"Reading WEAVIATE_URL/WEAVIATE_API_KEY from env vars that are unset in the deployed environment; typos in kwarg names passing values that never land on the fields; config files with blank values.","solutions":["Provide both values explicitly: WeaviateVectorSearchTool(weaviate_cluster_url='https://your.weaviate.network', weaviate_api_key='...').","Set and verify env vars (WEAVIATE_URL, WEAVIATE_API_KEY) at startup with an assertion.","Log the resolved config (names only, never the key value) before running the tool to spot empty fields."],"exampleFix":"# before\ntool.run('query')  # one of cluster_url/api_key empty -> ValueError\n\n# after\nimport os\nurl = os.environ['WEAVIATE_URL']\nkey = os.environ['WEAVIATE_API_KEY']\ntool = WeaviateVectorSearchTool(\n    weaviate_cluster_url=url, weaviate_api_key=key\n)\ntool.run('query')","handlingStrategy":"validation","validationCode":"import os\n\nurl = os.environ.get('WEAVIATE_URL', '').strip()\nkey = os.environ.get('WEAVIATE_API_KEY', '').strip()\nif not url or not key:\n    raise SystemExit('WEAVIATE_URL and WEAVIATE_API_KEY must both be set')","typeGuard":null,"tryCatchPattern":"try:\n    out = tool.run(query)\nexcept ValueError as e:\n    if 'WEAVIATE_URL or WEAVIATE_API_KEY' in str(e):\n        raise SystemExit('Provide weaviate_cluster_url and weaviate_api_key')\n    raise","preventionTips":["Validate both Weaviate fields (and strip whitespace) before constructing the tool.","Fail fast on missing secrets at startup rather than at first query.","Use exact kwarg names weaviate_cluster_url / weaviate_api_key."],"tags":["configuration","api-key","weaviate","validation"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}