spring-projects/spring-ai · error · RuntimeException
Collection {collectionName} with the tenant: {tenantName} an
Error message
Collection {collectionName} with the tenant: {tenantName} and the database: {databaseName} doesn't exist and won't be created as the initializeSchema is set to false. What it means
In ChromaVectorStore.afterPropertiesSet, when the configured collection does not exist on the Chroma server and initializeSchema is false, the store refuses to silently proceed and throws this RuntimeException. It guards against a misconfigured store pointing at a collection that will never exist.
Source
Thrown at vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java:135
if (!this.initialized) {
var collection = this.chromaApi.getCollection(this.tenantName, this.databaseName, this.collectionName);
if (collection == null) {
if (this.initializeSchema) {
var tenant = this.chromaApi.getTenant(this.tenantName);
if (tenant == null) {
this.chromaApi.createTenant(this.tenantName);
}
var database = this.chromaApi.getDatabase(this.tenantName, this.databaseName);
if (database == null) {
this.chromaApi.createDatabase(this.tenantName, this.databaseName);
}
collection = this.chromaApi.createCollection(this.tenantName, this.databaseName,
new ChromaApi.CreateCollectionRequest(this.collectionName));
}
else {
throw new RuntimeException("Collection " + this.collectionName + " with the tenant: "
+ this.tenantName + " and the database: " + this.databaseName
+ " doesn't exist and won't be created as the initializeSchema is set to false.");
}
}
Assert.state(collection != null, "collection should pre-exist or have been initialized.");
this.collectionId = collection.id();
this.initialized = true;
}
}
@Override
public void doAdd(List<Document> documents) {
Assert.notNull(documents, "Documents must not be null");
if (CollectionUtils.isEmpty(documents)) {
return;
}
List<String> ids = new ArrayList<>();View on GitHub (pinned to 98a7beda4f)
Solutions
- Set initializeSchema(true) on the builder so the store creates the missing collection.
- Create the collection manually (e.g. via the Chroma client or HTTP API) before starting the app.
- Verify collectionName, tenantName and databaseName match what exists on the Chroma server (check with a client listCollections call).
- Fix typos introduced by environment-specific configuration.
Example fix
// before
ChromaVectorStore.builder(chromaApi, embeddingModel).collectionName("my_coll").initializeSchema(false).build();
// after
ChromaVectorStore.builder(chromaApi, embeddingModel).collectionName("my_coll").initializeSchema(true).build(); Defensive patterns
Strategy: validation
Validate before calling
boolean exists = chromaApi.listCollections(tenantName, databaseName).stream()
.anyMatch(c -> c.name().equals(collectionName));
if (!exists && !initializeSchema) {
throw new IllegalStateException("Collection " + collectionName + " missing; set initializeSchema=true or create it");
} Type guard
null
Try / catch
try {
vectorStore.afterPropertiesSet();
} catch (RuntimeException e) {
if (e.getMessage().contains("doesn't exist")) {
chromaApi.createCollection(tenantName, databaseName, new CreateCollectionRequest(collectionName));
}
} Prevention
- Set initializeSchema(true) in dev/test environments so collections are auto-created.
- Provision collections in deployment scripts before app startup when initializeSchema is false.
- Keep collection/tenant/database names per-environment in config, not hardcoded.
- List collections via the Chroma client to verify names match exactly (case-sensitive).
When it happens
Trigger: Initializing ChromaVectorStore with initializeSchema=false while the collection name (with the given tenant/database) is absent from the Chroma server.
Common situations: Reusing a config file across environments (dev had the collection, prod doesn't); typo in collection name; tenant/database name mismatch; forgetting that initializeSchema defaults to false in some builder paths.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Failed to initialize ChromaVectorStore
- Index %s does not exist in table %s
- Failed to delete documents by filter
- Collection loading failed!
- Failed to create collection
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/9552356c4c75628c.
Report an issue: GitHub.