question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request parameter name cannot start with $ sign - regression

See original GitHub issue

The following has been observed in spring-cloud-openfeign when using request parameter name that starts with $ sign. It’s been caused by upgrading to version 10.x.

The issue has been reported here https://github.com/spring-cloud/spring-cloud-openfeign/issues/109.

public interface Client {
@GetMapping("/api")
    Result api(@RequestParam("$filter") String filter);
}

Calling client.api("123") used to work in any 2.0.x release even 2.1.0.RC2 was fine. Java call was translated into

GET /api?%24filter=123 HTTP/1.1

After upgrading to 2.1.0.RELEASE or 2.1.0.RC3 it looks like this

GET /api?%24filter=%7B%24filter%7D HTTP/1.1

The {$filter} query param is passed correctly to Feign, but there as it’s being converted into a feign.template.Expressions type feign.template.TemplateChunk, it does not pass the following pattern matching filter:

static {
    expressions = new LinkedHashMap<>();
    expressions.put(Pattern.compile("\\+(\\w[-\\w.]*[ ]*)(:(.+))?"), ReservedExpression.class);
    expressions.put(Pattern.compile("(\\w[-\\w.]*[ ]*)(:(.+))?"), SimpleExpression.class);
}
Optional<Entry<Pattern, Class<? extends Expression>>> matchedExpressionEntry =
        expressions.entrySet()
            .stream()
            .filter(entry -> entry.getKey().matcher(expression).matches())
            .findFirst();

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
wilersoncommented, May 14, 2019

I’ve looked into this further and the root cause of your issue is that Feign expects URI template expressions to validate against RFC 6570 template expressions. Expressions that start with a $ are not allowed. This is why the expression is being passed over and treated as a literal.

I might have missed something, but does RFC 6570 not allow for pct-encoded values? Because I still had this issue when using "%24filter".

Using a Map still works, of course, so that’s the workaround I ended up resorting to.

1reaction
ojecboreccommented, Feb 21, 2019

This workaround works as expected. Although as the list of parameters gets bigger it’s better to keep everything in one place, i.e. method parameters.

Another way how to provide parameters is a Map. Client definition would be

public interface Client {
   @GetMapping("/api")
   Result api(@RequestParam Map<String, String> parameters);
}

And you can call it

Map<String, String> parameters = new HashMap<>();
parameters.put("$filter", "123");
parameters.put("$select", "123");

client.api(parameters);

Funny thing is that this time it works without workdaround and the $ character in the parameter name is not a problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - How to get query parameter name from ... - Stack Overflow
The problem is, I cannot find an object that is carrying query parameter name. Seems like the ConstraintViolationException doesn't have it. I ...
Read more >
Troubleshoot the Regression suite automation tool
To troubleshoot errors when generating test execution and parameter files, enable generator logs. Open the Microsoft.Dynamics.RegressionSuite.
Read more >
Python - Variable Names - W3Schools
Rules for Python variables: A variable name must start with a letter or the underscore character; A variable name cannot start with a...
Read more >
Error/Warning Messages - Estima
Called Parameter by Value? If a PROCEDURE parameter is called by value, you cannot change the value stored in that variable. If necessary,...
Read more >
Visual Studio 2022 "Value cannot be null. Parameter name ...
9Votes. Visual Studio 2022 "Value cannot be null. Parameter name textView" on Ctrl-f quick find.. SDSteve Doiel. - Reported Dec 09, 2021. [regression]...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found