Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle unsupported media type properly for streaming requests #15531

Merged
merged 1 commit into from
Aug 31, 2024

Conversation

reta
Copy link
Collaborator

@reta reta commented Aug 30, 2024

Description

Handle unsupported media type properly for streaming requests

Related Issues

Fixes the NPE in RestBulkStreamingAction when content type header (media type) is not specified:

java.lang.NullPointerException: Cannot invoke "org.opensearch.core.xcontent.MediaType.mediaTypeWithoutParameters()" because "mediaType" is null                    
        at org.opensearch.rest.action.document.RestBulkStreamingAction.lambda$prepareRequest$6(RestBulkStreamingAction.java:127) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]                                                                                                                                                                    
        at org.opensearch.rest.action.document.RestBulkStreamingAction.lambda$prepareRequest$7(RestBulkStreamingAction.java:213) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]                                                                                                                                                                    
        at org.opensearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:128) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]                                    
        at org.opensearch.rest.RestController.dispatchRequest(RestController.java:383) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]                              
        at org.opensearch.rest.RestController.tryAllHandlers(RestController.java:474) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]        

How to reproduce:

$ curl -X POST http://localhost:9200/_bulk/stream  -d '
{ "delete": { "_index": "movies", "_id": "tt2229499" } }
'

now returns:

{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
Copy link
Contributor

❌ Gradle check result for d81b1d4: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for d81b1d4: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@reta reta added the backport 2.x Backport to 2.x branch label Aug 30, 2024
Copy link
Contributor

❕ Gradle check result for d81b1d4: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

Copy link

codecov bot commented Aug 30, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 71.90%. Comparing base (1d5082e) to head (d81b1d4).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
.../main/java/org/opensearch/rest/RestController.java 25.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #15531      +/-   ##
============================================
- Coverage     72.01%   71.90%   -0.12%     
- Complexity    63603    63605       +2     
============================================
  Files          5247     5247              
  Lines        297186   297189       +3     
  Branches      42939    42940       +1     
============================================
- Hits         214023   213683     -340     
- Misses        65610    66023     +413     
+ Partials      17553    17483      -70     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@reta
Copy link
Collaborator Author

reta commented Aug 30, 2024

@andrross @dblock minor fix for possible NPE, would appreciate a look, thank you!

@andrross andrross merged commit 03d9a24 into opensearch-project:main Aug 31, 2024
70 of 71 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 31, 2024
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
(cherry picked from commit 03d9a24)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
reta pushed a commit that referenced this pull request Aug 31, 2024
#15544)

(cherry picked from commit 03d9a24)

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
akolarkunnu pushed a commit to akolarkunnu/OpenSearch that referenced this pull request Sep 10, 2024
dk2k pushed a commit to dk2k/OpenSearch that referenced this pull request Oct 16, 2024
dk2k pushed a commit to dk2k/OpenSearch that referenced this pull request Oct 17, 2024
dk2k pushed a commit to dk2k/OpenSearch that referenced this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch bug Something isn't working skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants