Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.HttpClientErrorException;

/**
* {@link ChromaVectorStore} is a concrete implementation of the {@link VectorStore}
Expand Down Expand Up @@ -117,7 +118,16 @@ public static Builder builder(ChromaApi chromaApi, EmbeddingModel embeddingModel
@Override
public void afterPropertiesSet() throws Exception {
if (!this.initialized) {
var collection = this.chromaApi.getCollection(this.tenantName, this.databaseName, this.collectionName);
//if the collection doesn't exist, chromaApi.getCollection will throw an exception
ChromaApi.Collection collection = null;
try {
collection = this.chromaApi.getCollection(this.tenantName, this.databaseName, this.collectionName);
}
catch (Exception ex) {
if (!(ex.getCause() instanceof HttpClientErrorException.NotFound)) {
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception handling logic checks ex.getCause() for HttpClientErrorException.NotFound, but if chromaApi.getCollection() directly throws HttpClientErrorException.NotFound (not wrapped), this check will fail and re-throw the exception incorrectly. Consider also checking if ex itself is an instance of HttpClientErrorException.NotFound before checking the cause: if (!(ex instanceof HttpClientErrorException.NotFound || ex.getCause() instanceof HttpClientErrorException.NotFound))

Suggested change
if (!(ex.getCause() instanceof HttpClientErrorException.NotFound)) {
if (!(ex instanceof HttpClientErrorException.NotFound || ex.getCause() instanceof HttpClientErrorException.NotFound)) {

Copilot uses AI. Check for mistakes.
throw ex;
}
}
if (collection == null) {
if (this.initializeSchema) {
var tenant = this.chromaApi.getTenant(this.tenantName);
Expand Down