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

Aperta Adatta ai principianti
#8,703 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, spring
Ambito
api, backend

Direzione di ricerca

Inizia da RequestParamParameterProcessor.processArgument in shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/annotation/RequestParamParameterProcessor.java, dove gli argomenti di tipo lista e array vengono convertiti con String.valueOf. Esamina i test dello Spring SDK e aggiungi una copertura di regressione per i parametri di query ripetuti, inclusi i caratteri speciali e il caso C++. La correzione è completa quando ogni elemento di lista o array viene inviato con lo stesso nome del parametro e viene preservata la risposta prevista dall’endpoint.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
8.9k
Fork
3.1k
Merge medio
2g 21h
PR unite (30g)
128

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/shenyu

Tutte le issue di apache/shenyu

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.