Skip to content

feat: warn when GET method has unannotated parameters #1194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dkswnkk
Copy link

@dkswnkk dkswnkk commented May 9, 2025

Summary

This PR addresses issue #1191 by adding a warning when a @FeignClient method is declared as GET but 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 GET methods, this leads to a body-less POST due to underlying HTTP client behavior (e.g., HttpURLConnection), which causes a discrepancy:

  • The client logs show the request as GET
  • The server receives the request as a POST
  • No request body is actually sent (Content-Length: 0)

This is difficult to debug and confusing in real-world applications.

Related core issue: OpenFeign/feign#2872

Implementation Details

  • Added logic in SpringMvcContract#parseAndValidateMetadata() to check for:
    • Method is declared as GET
    • Method has parameters
    • None of the parameters have HTTP-related annotations
  • If so, a warning is logged via SLF4J:
[OpenFeign Warning] Feign method 'public abstract Response com.example.Client.getSomething(java.lang.String)' is declared as GET with parameters, but none of the parameters are annotated (e.g. @RequestParam, @RequestHeader, @PathVariable, etc). This may result in fallback to POST at runtime. Consider explicitly annotating parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants