Skip to content

[BUG] SQL returns 500 StringIndexOutOfBoundsException for an empty cursor #5983

Done

Description

@mengweieric

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 135d7db (3.10.0-SNAPSHOT), local integTest cluster
  • 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.

Activity

  1. added
    bug
    on Nov 25, 2026
  2. shuseng8 commented on Nov 26, 2026

    @shuseng8
    Contributor

    I'd like to work on this. I have a fix ready that returns HTTP 400 with "Cursor is empty or invalid" for an empty cursor on both _plugins/_sql and _plugins/_sql/close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buguntriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions