Skip to content

Commit fcc56f4

Browse files
jonasmuriboeilayaperumalg
authored andcommitted
Fix issue with CosmosDBVectorStore.Builder where the different Assert.hasText(..., "... must not be empty") evaluates the current value (null) rather than the argument passes to each builder function. Fix issue where partitionKeyPath is required, yet is never configured via CosmosDBVectorStoreAutoConfiguration
Signed-off-by: Jonas Muribø <jmurib@gmail.com>
1 parent fd9f388 commit fcc56f4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/cosmosdb/CosmosDBVectorStoreAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public CosmosDBVectorStore cosmosDBVectorStore(ObservationRegistry observationRe
7777
.metadataFields(List.of(properties.getMetadataFields()))
7878
.vectorStoreThroughput(properties.getVectorStoreThroughput())
7979
.vectorDimensions(properties.getVectorDimensions())
80+
.partitionKeyPath(properties.getPartitionKeyPath())
8081
.build();
8182

8283
}

vector-stores/spring-ai-azure-cosmos-db-store/src/main/java/org/springframework/ai/vectorstore/cosmosdb/CosmosDBVectorStore.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ private Builder(CosmosAsyncClient cosmosClient, EmbeddingModel embeddingModel) {
416416
* @throws IllegalArgumentException if containerName is null or empty
417417
*/
418418
public Builder containerName(String containerName) {
419-
Assert.hasText(this.containerName, "Container name must not be empty");
419+
Assert.hasText(containerName, "Container name must not be empty");
420420
this.containerName = containerName;
421421
return this;
422422
}
@@ -428,7 +428,7 @@ public Builder containerName(String containerName) {
428428
* @throws IllegalArgumentException if databaseName is null or empty
429429
*/
430430
public Builder databaseName(String databaseName) {
431-
Assert.hasText(this.databaseName, "Database name must not be empty");
431+
Assert.hasText(databaseName, "Database name must not be empty");
432432
this.databaseName = databaseName;
433433
return this;
434434
}
@@ -440,7 +440,7 @@ public Builder databaseName(String databaseName) {
440440
* @throws IllegalArgumentException if partitionKeyPath is null or empty
441441
*/
442442
public Builder partitionKeyPath(String partitionKeyPath) {
443-
Assert.hasText(this.partitionKeyPath, "Partition key path must not be empty");
443+
Assert.hasText(partitionKeyPath, "Partition key path must not be empty");
444444
this.partitionKeyPath = partitionKeyPath;
445445
return this;
446446
}
@@ -452,7 +452,7 @@ public Builder partitionKeyPath(String partitionKeyPath) {
452452
* @throws IllegalArgumentException if vectorStoreThroughput is not positive
453453
*/
454454
public Builder vectorStoreThroughput(int vectorStoreThroughput) {
455-
Assert.isTrue(this.vectorStoreThroughput > 0, "Vector store throughput must be positive");
455+
Assert.isTrue(vectorStoreThroughput > 0, "Vector store throughput must be positive");
456456
this.vectorStoreThroughput = vectorStoreThroughput;
457457
return this;
458458
}
@@ -464,7 +464,7 @@ public Builder vectorStoreThroughput(int vectorStoreThroughput) {
464464
* @throws IllegalArgumentException if vectorDimensions is not positive
465465
*/
466466
public Builder vectorDimensions(long vectorDimensions) {
467-
Assert.isTrue(this.vectorDimensions > 0, "Vector dimensions must be positive");
467+
Assert.isTrue(vectorDimensions > 0, "Vector dimensions must be positive");
468468
this.vectorDimensions = vectorDimensions;
469469
return this;
470470
}

0 commit comments

Comments
 (0)