feat: warn when GET method has unannotated parameters#1194
Merged
OlgaMaciaszek merged 2 commits intospring-cloud:mainfrom May 23, 2025
Merged
feat: warn when GET method has unannotated parameters#1194OlgaMaciaszek merged 2 commits intospring-cloud:mainfrom
OlgaMaciaszek merged 2 commits intospring-cloud:mainfrom
Conversation
Signed-off-by: JuHyeong <[email protected]>
OlgaMaciaszek
requested changes
May 21, 2025
Collaborator
OlgaMaciaszek
left a comment
There was a problem hiding this comment.
Hello @dkswnkk, thanks for submitting the PR. Have added a comment. Please address it.
| MethodMetadata metadata = super.parseAndValidateMetadata(targetType, method); | ||
|
|
||
| if (isGetMethod(metadata) && method.getParameterCount() > 0 && !hasHttpAnnotations(method)) { | ||
| LOG.warn(String.format( |
Collaborator
There was a problem hiding this comment.
Please use if (LOG.isWarnEnabled())[...]
Contributor
Author
There was a problem hiding this comment.
Thank you for your feedback.
I've updated the code to include the LOG.isWarnEnabled() check as you suggested.
Let me know if you have any further comments!
Signed-off-by: JuHyeong <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue #1191 by adding a warning when a
@FeignClientmethod is declared asGETbut has one or more parameters that are not annotated with any supported HTTP binding annotations (e.g.,@RequestParam,@RequestHeader,@PathVariable,@SpringQueryMap, etc.).Context
When no annotations are present, Feign may attempt to treat those parameters as a request body. For
GETmethods, this leads to a body-lessPOSTdue to underlying HTTP client behavior (e.g.,HttpURLConnection), which causes a discrepancy:GETPOSTContent-Length: 0)This is difficult to debug and confusing in real-world applications.
Related core issue: OpenFeign/feign#2872
Implementation Details
SpringMvcContract#parseAndValidateMetadata()to check for:GET