Bug Description

I'm trying to use the starter org.springframework.ai:spring-ai-opensearch-store-spring-boot-starter. However, I'm encountering the following error:

Caused by: java.lang.NullPointerException: Access key ID cannot be blank.
    at software.amazon.awssdk.utils.Validate.notNull(Validate.java:119)
    at software.amazon.awssdk.auth.credentials.AwsBasicCredentials.<init>(AwsBasicCredentials.java:68)
    at software.amazon.awssdk.auth.credentials.AwsBasicCredentials.<init>(AwsBasicCredentials.java:43)
    at software.amazon.awssdk.auth.credentials.AwsBasicCredentials$Builder.build(AwsBasicCredentials.java:238)
    at software.amazon.awssdk.auth.credentials.AwsBasicCredentials.create(AwsBasicCredentials.java:100)
    at org.springframework.ai.autoconfigure.vectorstore.opensearch.OpenSearchVectorStoreAutoConfiguration$AwsOpenSearchConfiguration.options(OpenSearchVectorStoreAutoConfiguration.java:156)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:146)
    ... 20 common frames omitted

Environment

Here are the relevant configuration properties being used:

My build.gradle:

ext {
    set('springAiVersion', "1.0.0-M4")
}

implementation 'org.springframework.ai:spring-ai-openai-spring-boot-starter'
implementation 'org.springframework.ai:spring-ai-opensearch-store-spring-boot-starter'
implementation 'software.amazon.awssdk:s3:2.29.1' 
implementation 'software.amazon.awssdk:ses:2.29.1'
spring.ai.vectorstore.opensearch.uris=http://elasticsearch.my-domain.com
spring.ai.vectorstore.opensearch.initialize-schema=true

Problem Analysis

The issue arises when using other AWS service libraries (e.g., S3, SQS, or any service under the classpath software.amazon.awssdk.regions.Region). The OpenSearchVectorStoreAutoConfiguration only instance "default http client", if 'aws' classes aren't present in classpath:

@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingClass({ "software.amazon.awssdk.regions.Region",
        "software.amazon.awssdk.http.apache.ApacheHttpClient" })
static class OpenSearchConfiguration {
    // Configuration details
}

This design assumes that AWS credentials are required, even for non-AWS use cases (like my case.... I need only a simple HTTP connection), leading to the error above. It becomes impossible to configure and use OpenSearch plain HTTP + other AWS libs.


Expected Behavior

I should be able to use spring-ai-opensearch-store-spring-boot-starter with a self-hosted Elasticsearch server without requiring AWS authentication.


Proposed Solution

The OpenSearchVectorStoreAutoConfiguration class should be updated to:

  1. Allow for a configuration path where AWS credentials are optional.
  2. Skip AWS-specific instantiation logic when credentials are not provided, enabling compatibility with non-AWS environments.