[BUG] SQL returns 500 StringIndexOutOfBoundsException for an empty cursor

オープン 初心者向け
#5,983 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
api

調査の方向性

障害は RestSqlAction.isLegacyCursor に起因します。このメソッドは空文字列かどうかを確認せずに cursor.substring(0, 1) を呼び出しています(RestSqlAction.java の251行目付近)。_plugins/_sql と _plugins/_sql/close のどちらもこのクラスを経由します。各エンドポイントに {"cursor": ""} を POST して再現させたうえで、空のカーソルに対して HTTP 400 を返すガードを追加してください。両方のエンドポイントが空のカーソルに対して 400 を返し、それをテストが検証していれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug untriaged

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 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.

主要言語
Java
スター
176
フォーク
237
平均マージ
2日 12時間
マージ済み PR(30日)
34

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

opensearch-project/sql のほかの issue

opensearch-project/sql の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。