{"record":{"id":"9552356c4c75628c","repo":"spring-projects/spring-ai","slug":"collection-collectionname-with-the-tenant-tena","errorCode":null,"errorMessage":"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.","messagePattern":"Collection (.+?) with the tenant: (.+?) and the database: (.+?) doesn't exist and won't be created as the initializeSchema is set to false\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java","lineNumber":135,"sourceCode":"\t\tif (!this.initialized) {\n\t\t\tvar collection = this.chromaApi.getCollection(this.tenantName, this.databaseName, this.collectionName);\n\t\t\tif (collection == null) {\n\t\t\t\tif (this.initializeSchema) {\n\t\t\t\t\tvar tenant = this.chromaApi.getTenant(this.tenantName);\n\t\t\t\t\tif (tenant == null) {\n\t\t\t\t\t\tthis.chromaApi.createTenant(this.tenantName);\n\t\t\t\t\t}\n\n\t\t\t\t\tvar database = this.chromaApi.getDatabase(this.tenantName, this.databaseName);\n\t\t\t\t\tif (database == null) {\n\t\t\t\t\t\tthis.chromaApi.createDatabase(this.tenantName, this.databaseName);\n\t\t\t\t\t}\n\n\t\t\t\t\tcollection = this.chromaApi.createCollection(this.tenantName, this.databaseName,\n\t\t\t\t\t\t\tnew ChromaApi.CreateCollectionRequest(this.collectionName));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new RuntimeException(\"Collection \" + this.collectionName + \" with the tenant: \"\n\t\t\t\t\t\t\t+ this.tenantName + \" and the database: \" + this.databaseName\n\t\t\t\t\t\t\t+ \" doesn't exist and won't be created as the initializeSchema is set to false.\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tAssert.state(collection != null, \"collection should pre-exist or have been initialized.\");\n\t\t\tthis.collectionId = collection.id();\n\t\t\tthis.initialized = true;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void doAdd(List<Document> documents) {\n\t\tAssert.notNull(documents, \"Documents must not be null\");\n\t\tif (CollectionUtils.isEmpty(documents)) {\n\t\t\treturn;\n\t\t}\n\n\t\tList<String> ids = new ArrayList<>();","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java#L117-L153","documentation":"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.","triggerScenarios":"Initializing ChromaVectorStore with initializeSchema=false while the collection name (with the given tenant/database) is absent from the Chroma server.","commonSituations":"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.","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."],"exampleFix":"// before\nChromaVectorStore.builder(chromaApi, embeddingModel).collectionName(\"my_coll\").initializeSchema(false).build();\n// after\nChromaVectorStore.builder(chromaApi, embeddingModel).collectionName(\"my_coll\").initializeSchema(true).build();","handlingStrategy":"validation","validationCode":"boolean exists = chromaApi.listCollections(tenantName, databaseName).stream()\n    .anyMatch(c -> c.name().equals(collectionName));\nif (!exists && !initializeSchema) {\n  throw new IllegalStateException(\"Collection \" + collectionName + \" missing; set initializeSchema=true or create it\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  vectorStore.afterPropertiesSet();\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"doesn't exist\")) {\n    chromaApi.createCollection(tenantName, databaseName, new CreateCollectionRequest(collectionName));\n  }\n}","preventionTips":["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)."],"tags":["chroma","collection","entity-not-found","vector-store","initialization"],"backgroundTag":"entity-not-found","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}