@RequestHeader overrides @PathVariable with the same name
维护者通常 1 天内回复
@rajeshvasa 已经在做这个了。
开始于 2026年11月18日。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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);
}
- 主要语言
- Java
- 星标
- 1.3k
- 派生
- 834
- 平均合并
- 3 天 6 小时
- 30 天内合并 PR
- 14
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
spring-cloud/spring-cloud-openfeign 的其他 Issue
-
question
难度 4/5 3-5 天 新手友好度 35/100
spring-cloud/spring-cloud-openfeign#1392 · 1 条评论 ·
维护者通常 1 天内回复
-
FeignClientsConfiguration$MicrometerConfiguration.class cannot be opened because it does not exist未关闭feedback-provided
难度 4/5 3-5 天 新手友好度 35/100
spring-cloud/spring-cloud-openfeign#1379 · 5 条评论 ·
维护者通常 1 天内回复
-
waiting-for-triage
难度 3/5 1-2 天 新手友好度 45/100
spring-cloud/spring-cloud-openfeign#1340 · 1 条评论 ·
维护者通常 1 天内回复
-
dependencies
难度 3/5 1-2 天 新手友好度 55/100
spring-cloud/spring-cloud-openfeign#1334 · 11 条评论 · 4 个 reaction ·
维护者通常 1 天内回复
-
waiting-for-triage
难度 4/5 3-5 天 新手友好度 35/100
spring-cloud/spring-cloud-openfeign#1309 · 7 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 spring-cloud/spring-cloud-openfeign 的全部 Issue
相似的 Issue
-
area:cpan-port area:performance bug
难度 2/5 1-3 小时 新手友好度 72/100
fglock/PerlOnJava#2230 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 82/100
federicoiosue/Omni-Notes#1044 ·
-
Bug
难度 1/5 1 小时以内 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复