@RequestHeader overrides @PathVariable with the same name

Aperta
#1,465 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@rajeshvasa ci sta già lavorando.

Dal 18/11/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
64/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, spring
Ambito
api, backend

Direzione di ricerca

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.

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

Descrizione

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);
}
Lingua principale
Java
Stelle
1.3k
Fork
834
Merge medio
3g 6h
PR unite (30g)
14

Preparare l'ambiente

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

Tutte le issue di spring-cloud/spring-cloud-openfeign

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.