Fix PPL REST handler returning 500 for OpenSearchRejectedExecutionException#5512
Draft
aravindsagar wants to merge 1 commit into
Draft
Fix PPL REST handler returning 500 for OpenSearchRejectedExecutionException#5512aravindsagar wants to merge 1 commit into
aravindsagar wants to merge 1 commit into
Conversation
…eption RestPPLQueryAction.getRawErrorCode() had a hardcoded `return 500` fallback for exceptions that aren't OpenSearchException or known client errors. This meant OpenSearchRejectedExecutionException (which extends RejectedExecutionException, not OpenSearchException) always surfaced as HTTP 500 instead of 429. Replace the hardcoded fallback with ExceptionsHelper.status(ex).getStatus(), which already handles OpenSearchRejectedExecutionException -> TOO_MANY_REQUESTS mapping in OpenSearch core. Signed-off-by: Aravind Sagar <sagarara@amazon.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Description
RestPPLQueryAction.getRawErrorCode()has a hardcodedreturn 500fallback for exceptions that don't matchOpenSearchExceptionor the known client-error list.OpenSearchRejectedExecutionExceptionextendsRejectedExecutionException→RuntimeException(notOpenSearchException), so it always fell through to the 500 path — even though OpenSearch core'sExceptionsHelper.status()already maps it toTOO_MANY_REQUESTS(429).This affects any backend that throws
OpenSearchRejectedExecutionExceptionthrough the PPL query path (e.g., admission control rejections from the analytics engine under memory pressure).Changes
return 500withreturn ExceptionsHelper.status(ex).getStatus()— delegates to the same mapping used by DSL_searchand the rest of OpenSearchRestPPLQueryActionTestwith unit tests covering the key exception→status mappingsTesting
Unit tests (all pass):
testRejectedExecutionReturns429— the primary fix scenariotestOpenSearchStatusExceptionPreservesStatus— verifies OpenSearchException path still works (404)testIndexNotFoundReturns404— IndexNotFoundException (extends OpenSearchException)testSyntaxCheckExceptionReturns400— client error pathtestQueryEngineExceptionReturns400— client error pathtestGenericRuntimeExceptionReturns500— unknown exceptions still return 500Full plugin test suite:
./gradlew :opensearch-sql-plugin:test— all existing tests pass.Manual end-to-end verification (local single-node cluster with DataFusion analytics backend):
admission_rejected_error) in the native query engineNativeErrorConvertercorrectly converted the native error string toOpenSearchRejectedExecutionException/_plugins/_pplreturned HTTP 500 / INTERNAL_SERVER_ERROR/_plugins/_pplreturned HTTP 429 / TOO_MANY_REQUESTS/_searchpath confirmed returning 429 both before and after (it already usesExceptionsHelper.status())Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--signoffor-s.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.