opensearch-project / opensearch-project/opensearch-java

[BUG] AwsSdk2Transport doesn't work with AwsSdk below 2.25.0

Open
#1,783 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
165
Forks
250
Avg merge
1d 18h
Merged PRs (30d)
26

Description

What is the bug?

Actually, it’s not really a bug. I think it’s an intended behavior that AwsSdk2Transport doesn’t work with AwsSdk below version 2.25.0, since that version is already quite old.

In the prepareRequest method of the AwsSdk2Transport class, the ContentStreamProvider interface calls the fromByteArrayUnsafe method. However, this method was introduced in AwsSdk2 after version 2.26.0.

Therefore, when using AwsSdk below 2.25.0, a NoSuchMethodError will occur when AwsSdk2Transport executes the prepareRequest method.

For clarification, it would be better to mention in the README which versions of AwsSdk2 are supported, so that users with older versions (below 2.25.0) can be aware of this limitation.

How can one reproduce the bug?

Inject SdkHttpClient of AwsSdk 2.25.0 into AwsSdk2Transport and then, call prepareRequest method.

SdkHttpClient httpClient =
        ApacheHttpClient.builder()
            .buildWithDefaults(
                AttributeMap.builder()
                    .put(SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, true)
                    .build());

    AwsSdk2Transport transport =
        new AwsSdk2Transport(
            httpClient,
            server.httpsUri().toString().replace("https://", ""),
            Region.AP_NORTHEAST_1,
            AwsSdk2TransportOptions.builder().setCredentials(CREDENTIALS_PROVIDER).build());
What is the expected behavior?

Mentioning which versions of AwsSdk2 are supported in README.

What is your host/environment?

Mac OS 15.3.1

Do you have any screenshots?
'software.amazon.awssdk.http.ContentStreamProvider software.amazon.awssdk.http.ContentStreamProvider.fromByteArrayUnsafe(byte[])'
java.lang.NoSuchMethodError: 'software.amazon.awssdk.http.ContentStreamProvider software.amazon.awssdk.http.ContentStreamProvider.fromByteArrayUnsafe(byte[])'
	at org.opensearch.client.transport.aws.AwsSdk2Transport.prepareRequest(AwsSdk2Transport.java:348)
	at org.opensearch.client.transport.aws.AwsSdk2Transport.performRequest(AwsSdk2Transport.java:215)

Image
Do you have any additional context?

Add any other context about the problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by checking the README for the AwsSdk2Transport dependency or compatibility documentation, then review AwsSdk2Transport.prepareRequest and the reported ContentStreamProvider method version. Document the supported AWS SDK versions, including the minimum version that provides fromByteArrayUnsafe, and confirm the README clearly warns users of older versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.