[BugFix] Return 400 for an empty SQL cursor (#5983) #5992
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 317 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.345
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #5992"
general
weight: 0.35
Swiddis
Description
A request with an empty cursor (
POST _plugins/_sqlorPOST _plugins/_sql/closewith{"cursor": ""}) returned HTTP 500 andStringIndexOutOfBoundsException. This is a bad request, so it should return 400.RestSqlAction.isLegacyCursorcalledcursor.substring(0, 1)without checking for an empty string. Both endpoints are handled byRestSqlAction, and an empty cursor never reached a meaningful legacy or v2 engine path because it crashed first.This change:
SqlRequestFactorywithIllegalArgumentException("Cursor is empty or invalid"), whichRestSqlActionalready maps to HTTP 400 on both/_plugins/_sqland/_plugins/_sql/close.isLegacyCursorskip empty cursors sosubstring(0, 1)cannot throw if an empty cursor is constructed some other way.Related Issues
Resolves #5983
Check List
- Unit tests in
SqlRequestFactoryTest(valid, empty, and blank cursors) andRestSqlActionTest(empty cursor is a 400,isLegacyCursordoes not throw on empty or null and still detects legacy vs v2 cursors).- Integration tests in
CursorITforPOST _plugins/_sqlandPOST _plugins/_sql/closewith{"cursor": ""}, asserting HTTP 400 and the error details.- [ ] New functionality has javadoc added.
- [ ] New functionality has a user manual doc added.
--signoffor-s.Tested locally with
./gradlew :legacy:spotlessCheck :integ-test:spotlessCheck :legacy:test(1534 tests, 0 failures, 26 skipped) and./gradlew :integ-test:integTest -Dtests.class="org.opensearch.sql.legacy.CursorIT" -Dtests.method="emptyCursor*" -DignorePrometheus(both new tests passed).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.