@RequestHeader overrides @PathVariable with the same name

Abierto
#1,465 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@rajeshvasa ya está trabajando en esto.

Desde el 18/11/2026.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
64/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java, spring
Área
api, backend

Línea de trabajo

Start by tracing how Spring Cloud OpenFeign resolves @PathVariable and @RequestHeader parameters when they share a name, then find the related request mapping tests. Reproduce the sample request and verify that the URI uses 1 for {id} while the header remains A. Add a regression test for the behavior and run the relevant tests.

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

Descripción

waiting-for-triage

Describe the bug

If @RequestHeader and @PathVariable have the same name, the header value is inserted to the uri template instead of the path variable.

Spring HTTP Service Clients does not have this problem.

Sample

interface TestApi {
    @GetMapping(value = "/test/{id}")
    void test(@PathVariable Integer id, @RequestHeader("id") String headerId);
}

@FeignClient(name = "testClient", url = "http://localhost:8080")
interface TestClient extends TestApi {
}

@RestController
class TestController implements TestApi {
    public void test(Integer id, String headerId) {
    }
}

@SpringBootApplication
@EnableFeignClients
class SampleApplication implements ApplicationRunner {

    @Autowired
    private TestClient testClient;

    public void run(ApplicationArguments args) {
        // this requests test/A instead of test/1
        testClient.test(1, "A");
    }

    public static void main(String[] args) {
        SpringApplication.run(SampleApplication.class, args);
    }
}

Dependencies:

    implementation(platform("org.springframework.boot:spring-boot-dependencies:4.1.2"))
    implementation(platform("org.springframework.cloud:spring-cloud-dependencies:2025.1.4"))
    implementation(platform("io.github.openfeign:feign-bom:13.18"))
    implementation("org.springframework.boot:spring-boot-starter-webmvc")
    implementation("org.springframework.cloud:spring-cloud-starter-openfeign")

If using Spring HTTP Service Clients, the problem is not reproduced:

interface TestClient {
    @GetExchange("/test/{id}")
    void test(@PathVariable Integer id, @RequestHeader("id") String headerId);
}
Lenguaje dominante
Java
Estrellas
1.3k
Forks
834
Merge medio
3 d 6 h
PR fusionados (30 d)
14

Preparar el entorno

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 spring-cloud/spring-cloud-openfeign

Todos los issues de spring-cloud/spring-cloud-openfeign

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.