[BUG] Spring SDK sends List and array query parameters as a single string

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

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java, spring
領域
api, backend

調査の方向性

shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/annotation/RequestParamParameterProcessor.java の RequestParamParameterProcessor.processArgument から始めます。ここでは、リスト引数と配列引数が String.valueOf で変換されます。Spring SDK のテストを確認し、特殊文字や C++ の場合を含む、繰り返しクエリパラメータの回帰カバレッジを追加してください。各リスト要素または配列要素が同じパラメータ名で送信され、期待されるエンドポイントのレスポンスが保持された時点で修正は完了です。

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

説明

type: bug
Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

A named @RequestParam in the ShenYu Spring SDK sends a list as one query value containing the Java list’s string representation. A String[] is also sent as one value, with a Java object string such as [Ljava.lang.String;@....

Expected Behavior

I expected one query value per element under the same name. For example, List.of("red", "blue") should be sent as ?tag=red&tag=blue.

Steps To Reproduce

Point a ShenYu Spring client at a Spring MVC endpoint with these declarations:

@ShenyuClient(name = "colors")
public interface ColorsClient {
    @GetMapping("/colors")
    ShenyuResponse colors(@RequestParam("tag") List<String> tags);
}

@RestController
public class ColorsController {
    @GetMapping("/colors")
    public String colors(@RequestParam("tag") List<String> tags) {
        return String.join("|", tags);
    }
}

Call client.colors(List.of("red", "north & south=east", "茶", "red", "C++")). The endpoint returned HTTP 200, but the response body was [red|north & south=east|茶|red|C ] (two spaces after C). I expected red|north & south=east|茶|red|C++.

Environment
ShenYu master (`7c08840`), JDK 21, Apache HttpClient transport, Spring MVC 6.2.19.
Debug logs

No response

Anything else?

In RequestParamParameterProcessor.processArgument, the list or array is stored as one value, then passed to String.valueOf before URL encoding.

Is it OK to make repeated parameters the default for lists and arrays, or should the SDK preserve the old format for endpoints that expect one value? If repeated parameters are the intended behavior, I’ll submit the fix with regression tests.

主要言語
Java
スター
8.9k
フォーク
3.1k
平均マージ
2日 21時間
マージ済み PR(30日)
128

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

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

apache/shenyu のほかの issue

apache/shenyu の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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