[BUG] SQL returns 500 StringIndexOutOfBoundsException for an empty cursor
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 85/100
Research direction
The failure comes from RestSqlAction.isLegacyCursor, which calls cursor.substring(0, 1) without checking for an empty string (around line 251 of RestSqlAction.java). Both _plugins/_sql and _plugins/_sql/close route through this class. Reproduce by POSTing {"cursor": ""} to each endpoint, then add an empty-cursor guard that returns HTTP 400. Done when both endpoints return 400 for an empty cursor and a test covers it.
Written by the indexing model from the issue text.
Description
What is the bug?
A request with an empty cursor returns HTTP 500 with StringIndexOutOfBoundsException. This is a bad request, so it should return 400.
How can one reproduce the bug?
POST _plugins/_sql
{"cursor": ""}
{
"error": {
"reason": "There was internal problem at backend",
"details": "Range [0, 1) out of bounds for length 0",
"type": "StringIndexOutOfBoundsException"
},
"status": 500
}
POST _plugins/_sql/close with the same body returns the same 500.
What is the expected behavior?
HTTP 400 with a message that the cursor is empty or invalid.
What is your host/environment?
- main at 135d7db4d (3.10.0-SNAPSHOT), local
integTestcluster - Plugins: opensearch-sql
Do you have any additional context?
RestSqlAction.isLegacyCursor calls cursor.substring(0, 1) without checking for an empty string (line 251). Both endpoints are handled by RestSqlAction.
- Dominant language
- Java
- Stars
- 176
- Forks
- 237
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 34
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from opensearch-project/sql
-
bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
opensearch-project/sql#5990 ·
Maintainers usually reply within 1 day
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"Possibly taken @nagendramohan claimed this 107 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
opensearch-project/sql#5684 · 4 comments ·
Maintainers usually reply within 1 day
-
[DOC] Calcite settings documentation missing examplesPossibly taken @AzazelSensei claimed this 64 days ago. Opendocumentation PPL
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
opensearch-project/sql#4806 · 1 comment ·
Maintainers usually reply within 1 day
-
calcite enhancement Meta performance PPL untriaged
Difficulty 5/5 Over a week Newbie friendliness 8/100
opensearch-project/sql#5991 ·
Maintainers usually reply within 1 day
-
bug duplicate untriaged
Difficulty 4/5 3-5 days Newbie friendliness 22/100
opensearch-project/sql#5989 · 1 comment ·
Maintainers usually reply within 1 day
All issues in opensearch-project/sql
Similar issues
-
chore
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
lugassawan/swe-workbench#841 ·
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
EndlessPixel-Studio/FakePlayer-CE#155 ·
Maintainers usually reply within 1 day
-
Document the isv:HDFGroup Linux package repositories and signing keyPossibly taken @brtnfld claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
checkstyle/checkstyle#23174 ·
Maintainers usually reply within 1 day