redhat-developer / redhat-developer/vscode-java
Spring "PathVariable annotation was empty on param" method mapping
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 546
- Avg merge
- 20h 1m
- Merged PRs (30d)
- 11
Description
I'm trying to test a FeignClient where I've defined a PathVariable using a @PathVariable String urlId but I'm receiving a PathVariable annotation was empty on param 0 when I attempt to run my tests. It works via a gradlew test but not in the VS Code test runner. I can resolve this by explicitly mapping @PathVariable(value = "urlId") String urlId but the documentation defines that as an optional field (https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/PathVariable.html).
I believe this is something related to the compiler, because gradlew test and IntelliJ can run the tests without the explicit mapping, but it only fails with the error in the VS Code test extension. Reading the spring docs it calls out in the input mapping that if it's compiled with the -parameters flag it will map the input to the method's parameters (https://docs.spring.io/spring-boot/reference/actuator/endpoints.html#actuator.endpoints.implementing-custom.input). I was able to successfully validate this in VS Code by going to the Java > Settings: Url and pointing it to a new settings.pref file I created that only contains the line org.eclipse.jdt.core.compiler.codegen.methodParameters=generate, which allowed the compiler to map without the explicit (value = "urlId") on the annotation. I'm not a huge fan of this approach however, because I'm positive I'm going to forget this every time I setup a new device, so I was wondering if this constituted an issue that could be rolled into the extension so this was supported without having to create a custom settings file any time I need to test a spring project with feign client.
For additional system details I'm running spring boot 3.4.1, with a gradle build it, on Java 21.0.6 (Amazon Corretto 21) on the Java Language Support extension version 1.41.0 (temporarily downgraded from 1.41.1 due to https://github.com/redhat-developer/vscode-java/issues/4002)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the described Spring Boot and FeignClient setup in the VS Code Java test runner, then inspect how the extension configures JDT compiler method-parameter generation compared with Gradle and IntelliJ. Done means @PathVariable String urlId works in the VS Code runner without a per-device settings.pref workaround, with regression coverage if the relevant test entry point is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100