Skip to content
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

IllegalArgumentException: Negated params are not supported #1134

Open
ragnor opened this issue Nov 29, 2024 · 5 comments
Open

IllegalArgumentException: Negated params are not supported #1134

ragnor opened this issue Nov 29, 2024 · 5 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ragnor
Copy link

ragnor commented Nov 29, 2024

After updating from 4.0.x to 4.1.4 I've noticed that my services cannot startup due to:

Caused by: java.lang.IllegalArgumentException: Negated params are not supported: !sync
at org.springframework.cloud.openfeign.support.SpringMvcContract.parseParams(SpringMvcContract.java:372) ~[spring-cloud-openfeign-core-4.1.4.jar:4.1.4]
at org.springframework.cloud.openfeign.support.SpringMvcContract.processAnnotationOnMethod(SpringMvcContract.java:249) ~[spring-cloud-openfeign-core-4.1.4.jar:4.1.4]
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:112) ~[feign-core-13.5.jar:na]
at org.springframework.cloud.openfeign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:198) ~[spring-cloud-openfeign-core-4.1.4.jar:4.1.4]
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:71) ~[feign-core-13.5.jar:na]
at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:140) ~[feign-core-13.5.jar:na]
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:59) ~[feign-core-13.5.jar:na]
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:51) ~[feign-core-13.5.jar:na]
at feign.Feign$Builder.target(Feign.java:202) ~[feign-core-13.5.jar:na]
at org.springframework.cloud.openfeign.DefaultTargeter.target(DefaultTargeter.java:30) ~[spring-cloud-openfeign-core-4.1.4.jar:4.1.4]
at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:504) ~[spring-cloud-openfeign-core-4.1.4.jar:4.1.4]
at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:456) ~[spring-cloud-openfeign-core-4.1.4.jar:4.1.4]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:182) ~[spring-beans-6.1.15.jar:6.1.15]
... 29 common frames omitted

Changes were introduced by c276f1c#diff-d7125c419c7e91db20fe7e903b744c180165b6271b6d68e5b966760eb1a3c067.

Is there any way to disable this check in SpringMvcContract?
I understand that feign doesn't use negated parameters but I use shared interfaces between server and client. Negated parameters are needed on server side to avoid ambiguous mappings.

@ragnor
Copy link
Author

ragnor commented Dec 2, 2024

I've noticed that Spring Cloud OpenFeign is already in maintenance mode and I should migrate to Spring Interface Clients.

Is there any official guide how to perform migration?

Does Spring Cloud OpenFeign support *Exchange annotations (e.g. @HttpExchange) so as a first step in migration I can change mapping descriptions in interfaces?

@OlgaMaciaszek
Copy link
Collaborator

Hello, @ragnor, thanks for creating the issue. We can consider it. Can you please provide a sample that illustrates your current scenario?

@ragnor
Copy link
Author

ragnor commented Dec 18, 2024

@OlgaMaciaszek a simple example to reproduce the issue:


public interface TokenApi {

 @PostMapping(path = "/api/token", params = {"!expiration"})
 String create();

 @PostMapping(path = "/api/token", params = {"expiration"})
 String create(@RequestParam LocalDateTime expiration);

}


@FeignClient(value = "token", url ="${feign.client.config.token.uri}", contextId = "tokenClient")
public interface TokenClient extends TokenApi {
}


@RestController
public class TokenController implements TokenApi {
 @Override
 public String create() {
   // calculate token ...
   return "a-token";
 }

 @Override
 public String create(LocalDateTime expiration) {
  // calculate token ...
   return "a-token-with-expiration";
 }
}

@kssumin
Copy link

kssumin commented Feb 25, 2025

I'd like to contribute for this issue.

My proposed solution is to add a configuration option to allow negated parameters while maintaining backward compatibility.

@OlgaMaciaszek
Please let me know if this solution aligns with the project's direction, and I'd be happy to submit a PR.

@OlgaMaciaszek
Copy link
Collaborator

Hello @kssumin, thanks for reaching out. Feel free to create a PR.

kssumin pushed a commit to kssumin/spring-cloud-openfeign that referenced this issue Mar 9, 2025
…cContract

- Added 'allowNegatedParams' configuration option to FeignClientProperties
- Modified SpringMvcContract to skip negated parameters when the feature is enabled
- Added tests for both enabled and disabled cases
- Updated documentation with usage examples
kssumin added a commit to kssumin/spring-cloud-openfeign that referenced this issue Mar 9, 2025
…cContract

- Added 'allowNegatedParams' configuration option to FeignClientProperties
- Modified SpringMvcContract to skip negated parameters when the feature is enabled
- Added tests for both enabled and disabled cases
- Updated documentation with usage examples
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2024.0.1 Mar 12, 2025
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2023.0.6 Mar 12, 2025
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2025.0.0-M3 Mar 12, 2025
@OlgaMaciaszek OlgaMaciaszek added this to the 4.1.5 milestone Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Status: In Progress
Status: In Progress
Development

Successfully merging a pull request may close this issue.

4 participants