Skip to content

[Bug]: Authentication with url and api key is not used instead DefaultAzureCredential() are used. Documentation lacks connection string support. #2155

@saketbyte

Description

@saketbyte

Do you need to file an issue?

  • I have searched the existing issues and this bug is not already filed.
  • My model is hosted on OpenAI or Azure. If not, please look at the "model providers" issue and don't file a new one here.
  • I believe this is a legitimate bug, not just a question. If this is a question, please use the Discussions area.

Describe the bug

In the cosmosdb.py file:
CosmosDBVectorStore.connect function is supposed to use (as per code) :

a. connection string for cosmos db [or]
b. DefaultAzureCredentials() and a connection end point url.

However in the documentation:
For a.
There is no mention of connection string to be passed as a parameter.

For b
There is no mention of vector_store.url being required for cosmos db as vector store, this is also been pointed out earlier in an issue.

When connection string is passed, the control goes to pydantic validations in vector_store_config.py raising an Exception for missing parameter ie vector_store.url in vector store configuration, although should not be required as per documentation, as documentation says it is only required for Azure AI Search and not Cosmos DB as vector store.

Hence Cosmos DB is not getting connected:

a. No mention of connection string.
b. Even if we use connection string, cannot connect because vector_store url is required is the error message which pops up, misleading, as parallel to url it requires Default Azure Credentials. Not mentioend in Docs.

Now, the conclusive issue because of a and b comes that if someone has received endpoint of cosmos db and api key which should be enough to access cosmosdb still, they cannot connect to cosmosdb for graph rag, because api key is not being used in cosmosdb.py file and connection string is not mentioned anywhere which can be composed of endpoint and api key to connect.

Files mentioned:
Line 53 graphrag/config/models/vector_store_config.py

if self.type == VectorStoreType.CosmosDB and (

Line 47 in cosmosdb.py,
graphrag/vector_stores/cosmosdb.py

self._cosmos_client = CosmosClient(

We see it is using url and DefaultAzureCredential().

Thank you !! It was fun to debug this, please correct me if there is a misunderstanding from my end. 😀

Steps to reproduce

Passing required parameters in settings.yaml as per docs to connect to cosmosDB client, without default azure credentials method, reproduces the issue.

Step 1 - using graph init
Step 2 - updating settings.yaml vector_store configuration as per docs. (It runs but database contains no embeddings, issue surfaces in querying.)
Step 3 - running a query on indexed information will reproduce the error.

Expected Behavior

Connect to Cosmos DB.

GraphRAG Config Used

# Paste your config here
vector_store:
  default_vector_store:
    url: ${vector_store_url}
    type: "cosmosdb"
    database_name: ${db_name}

Logs and screenshots

No response

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageDefault label assignment, indicates new issue needs reviewed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions