opensearch-java: [BUG] code works with local opensearch but not AOSS

What is the bug?

Using OpenSearchClient.get() to retrieve document. Works with a local opensearch (docker opensearch:2.13.0) but same code fails AOSS (amazon serverless) with 404.

How can one reproduce the bug?

Have example class that can be provided if this is the correct forum.

What is the expected behavior?

I except the same OpenSearchClient.get() to pass or fail independent of local opensearch or AOSS.

What is your host/environment?

Local: docker opensearch 2.13.0 AOSS: unknown

Do you have any screenshots?

No. Would not make sense without seeing the code. Here is the output from the test: local: Index already exists so delete it first local: Created the testing index local: Found expected document local: Found expected document local: Test complete aoss: Index already exists so delete it first aoss: Created the testing index aoss: Found expected document Exception in thread “main” org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [http_exception] server returned 404 at org.opensearch.client.transport.aws.AwsSdk2Transport.parseResponse(AwsSdk2Transport.java:498) at org.opensearch.client.transport.aws.AwsSdk2Transport.executeSync(AwsSdk2Transport.java:396) at org.opensearch.client.transport.aws.AwsSdk2Transport.performRequest(AwsSdk2Transport.java:193) at org.opensearch.client.opensearch.OpenSearchClient.get(OpenSearchClient.java:737) at example.ComparisonLocalVsServerless.doTest(ComparisonLocalVsServerless.java:110) at example.ComparisonLocalVsServerless.main(ComparisonLocalVsServerless.java:79)

Do you have any additional context?

We use cognito to exchange general username/password for access keys. We then use a lambda to convert those keys to AWS credentials because Java SDK does (did not) support cognito at the time of our testing. This lookup is included in the test code.

It seems that the failure seems to be related to the local opensearch using httpclient5 while the AOSS uses httpclient. The document ID that cannot be found contains many : in its name, like a:b:c:d:e::1.0.

@jordanpadams @tloubrieu-jpl

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 34 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Have noted on #1103 that I’m working on a fix for this difference in behaviour

thanks @workmanw and @dblock we will have a look. As @dblock mentioned, looks like the SNAPSHOT builds are failing right now, but we will look to build the code locally and go from there.

Released builds go to https://mvnrepository.com/artifact/org.opensearch.client/opensearch-java and daily SNAPSHOTS go to https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/client/opensearch-java/, so 2.11-SNAPSHOT should be good. I include it in a pom here as an example.

However, looks like the snapshot publication has been intermittently failing, so I am not sure this particular change made it yet, would grok through these builds and see if there’s a successful one after the backport into the 2.x branch. https://github.com/opensearch-project/opensearch-java/actions/workflows/publish-snapshots.yml. I opened https://github.com/opensearch-project/opensearch-java/issues/1090, not sure what’s going on.

I’d appreciate if someone trying this out could add a section to DEVELOPER_GUIDE or expand https://github.com/opensearch-project/opensearch-java/blob/main/README.md#snapshot-builds on how to use SNAPSHOT builds and where they are per above.

@workmanw Yes, would definitely merge with just the integration test.

FWIW I have debugged this already. Apologies if I wasn’t clear above, the problem is that AwsSdk2Transport has different response handling than ApacheHttpClient5Transport.

If you look here: ApacheHttpClient5Transport.java you’ll see an exception handler for MissingRequiredPropertyException, this is what ensures that the GetResponse object is deserilaized correctly.

Notice that that is missing from AwsSdk2Transport.java.

So I would be happy to fix this issue if you would accept it as having an integration test instead of a unit test. I would be happy to try to write a unit test, but to be honest I don’t have to expertise to take on a large test refactor like you mentioned with #503.

Hi @dblock ,

Sorry for the delay, I was able to add the logs you asked for. Our test script is getting that:

[DEBUG] wire - http-outgoing-0 >> "GET /tloubrieutest/_doc/a:b:c:d:e::1.2?_source_includes=product_class HTTP/1.1[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "Host: p5qmxrldysl1gy759hqf.us-west-2.aoss.amazonaws.com[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "Accept-Encoding: gzip[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "Authorization: AWS4-HMAC-SHA256 Credential=ASIAWNMVG7HD2RHFXCMS/20240711/us-west-2/aoss/aws4_request, SignedHeaders=accept-encoding;host;x-amz-date;x-amz-security-token, Signature=548a816b84df8284ecaa279445a3a9b8d0a804f2253f85ff5d391da5bc3a7b86[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "X-Amz-Date: 20240711T022015Z[\r][\n]"
[DEBUG] wire - http-outg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GtyZXlFpZTxyUoA1gkwZKU+Ou0ceu53LnvcW1WpE9GC2s6+1gSh3NcIqZa/ybwkeCmCttIm0ZvUzfFOfVAh9euRQ5XMntM7MRuGH1h4SuL3GZ+7nH94u29rQhys5j/70lc6OsrzoGfRwcbBX6klQPngZkBVCoOzXTI9lE8NMLx1EOqSiVtKzBji1KTTQHkAavCkQXLKjlxLyvBxJeoLE[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "User-Agent: [\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "HTTP/1.1 404 Not Found[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "x-request-id: 73403f0b-c95a-93ba-8fbe-04240f2d10d0[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "date: Thu, 11 Jul 2024 02:20:15 GMT[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "server: aoss-amazon[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "content-length: 0[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "[\r][\n]"
Exception in thread "main" org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [http_exception] server returned 404
	at org.opensearch.client.transport.aws.AwsSdk2Transport.parseResponse(AwsSdk2Transport.java:498)
	at org.opensearch.client.transport.aws.AwsSdk2Transport.executeSync(AwsSdk2Transport.java:396)
	at org.opensearch.client.transport.aws.AwsSdk2Transport.performRequest(AwsSdk2Transport.java:193)
	at org.opensearch.client.opensearch.OpenSearchClient.get(OpenSearchClient.java:737)
	at gov.nasa.pds.registry.common.ComparisonLocalVsServerless.doTest(ComparisonLocalVsServerless.java:160)
	at gov.nasa.pds.registry.common.ComparisonLocalVsServerless.main(ComparisonLocalVsServerless.java:87)

Whereas a document with this id is available in the index: image