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

Abierto Apto para principiantes
#8,703 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java, spring
Área
api, backend

Línea de trabajo

Comienza por RequestParamParameterProcessor.processArgument en shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/annotation/RequestParamParameterProcessor.java, donde los argumentos de tipo lista y array se convierten con String.valueOf. Revisa las pruebas del Spring SDK y añade cobertura de regresión para parámetros de consulta repetidos, incluidos caracteres especiales y el caso C++. La corrección estará completa cuando cada elemento de lista o array se envíe con el mismo nombre de parámetro y se conserve la respuesta esperada del endpoint.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Java
Estrellas
8.9k
Forks
3.1k
Merge medio
2 d 21 h
PR fusionados (30 d)
128

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/shenyu

Todos los issues de apache/shenyu

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.