{"record":{"id":"4d854313431f8f3d","repo":"microsoft/graphrag","slug":"specify-either-connection-string-or-account-url-4d8543","errorCode":null,"errorMessage":"Specify either 'connection_string' or 'account_url', not both.","messagePattern":"Specify either 'connection_string' or 'account_url', not both\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag-storage/graphrag_storage/tables/cosmos_table_provider.py","lineNumber":97,"sourceCode":"        if _container is not None:\n            # Fast path: child() or test injection.\n            self._cosmos_client = _cosmos_client\n            self._container = _container\n            self._legacy_container = _legacy_container\n            self._namespace = namespace\n            self._owns_client = False\n            return\n\n        # Normal construction from config values.\n        if not database_name:\n            msg = \"CosmosTableProvider requires 'database_name'.\"\n            raise ValueError(msg)\n        if not container_name:\n            msg = \"CosmosTableProvider requires 'container_name'.\"\n            raise ValueError(msg)\n        if connection_string and account_url:\n            msg = \"Specify either 'connection_string' or 'account_url', not both.\"\n            raise ValueError(msg)\n        if not connection_string and not account_url:\n            msg = \"CosmosTableProvider requires 'connection_string' or 'account_url'.\"\n            raise ValueError(msg)\n\n        if connection_string:\n            self._cosmos_client = CosmosClient.from_connection_string(connection_string)\n        else:\n            self._cosmos_client = CosmosClient(\n                url=account_url,  # type: ignore[arg-type]\n                credential=DefaultAzureCredential(),\n            )\n\n        self._namespace = namespace\n        self._owns_client = True\n\n        # Containers are created lazily on first use via _ensure_container().\n        self._database_name = database_name\n        self._container_name = container_name","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag-storage/graphrag_storage/tables/cosmos_table_provider.py#L79-L115","documentation":"CosmosTableProvider supports exactly one authentication route — connection string or account URL with AAD credentials. Providing both is rejected at construction to avoid ambiguity about which credential source governs the connection.","triggerScenarios":"Passing both connection_string and account_url to CosmosTableProvider, most often because a connection-string env var is set while the YAML also declares account_url (or vice versa).","commonSituations":"Shared env vars from another cosmos component injecting a connection string; config merging two example files that use different auth styles.","solutions":["Remove one of the two credentials from config/env","Unset the conflicting env var (e.g. GRAPHRAG_COSMOSDB_CONNECTION_STRING) if you intend account_url auth","Prefer account_url + managed identity in production"],"exampleFix":"# before\nconnection_string: ${COSMOS_CONN}\nurl: https://myacct.documents.azure.com\n# after\nurl: https://myacct.documents.azure.com","handlingStrategy":"validation","validationCode":"assert not (cfg.get(\"connection_string\") and cfg.get(\"url\")), \"one cosmos credential only\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose account_url+managed identity for prod; strip connection-string env vars"],"tags":["cosmosdb","auth","config-conflict","table-provider"],"backgroundTag":"conflicting-auth-config","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}