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.

URI encoded slahes in path parameters lead to action not found

See original GitHub issue

Lagom Version (1.2.x / 1.3.x / etc)

1.3.5 Dev Mode

API (Scala / Java / Neither / Both)

Java

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

4.4.0-77-generic #98-Ubuntu SMP Wed Apr 26 08:34:02 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

JDK

java version “1.8.0_131” Java™ SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot™ 64-Bit Server VM (build 25.131-b11, mixed mode)

Expected Behavior

When sending requests to the hello endpoint of the from archetype generated project, defined as pathCall("/api/hello/:id", this::hello), and the id parameter contains URI encoded slashes (http://localhost:9000/api/hello/Alice%2FThat%2Fis%2Fmy%2Fname), it should invoke the service method with the id provided.

Actual Behavior

A 404 - Action not found page is rendered. Stating that all routes have been tried but none is matching.

<h1>Action Not Found</h1>

        <p id="detail">
            For request 'GET /api/hello/Alice/That/is/my/name'
        </p>
...

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
TimMoorecommented, Aug 4, 2017

Just did a bit more testing:

  • When hitting the service gateway (curl http://localhost:9000/api/hello/Alice%2FThat%2Fis%2Fmy%2Fname) I get the 404 as reported
  • When hitting the service port directly (curl http://localhost:57797/api/hello/Alice%2FThat%2Fis%2Fmy%2Fname) I get the expected result: Hello, Alice/That/is/my/name!
  • If I enable the experimental akka-http service gateway that was added in #894, I also get the expected result from port 9000 🎉

So I’m going to call this fixed by #894. We don’t plan to continue fixing problems with the existing, netty-based service gateway, and the akka-http one will be the default in Lagom 1.4.

Until then, you can enable it in 1.3.7+ by:

  • sbt adding lagomServiceGatewayImpl in ThisBuild := "akka-http" to your build.sbt or
  • maven configuring the lagom maven plugin in the root POM with <serviceGatewayImpl>akka-http</serviceGatewayImpl>

1.3.7 has not been released yet, but there is a 1.3.7-RC1 pre-release build available in Maven Central that includes the new gateway, so if you need it urgently, you can use that.

0reactions
richdoughertycommented, Aug 2, 2017

OK thanks for confirming that. That behaviour is what we’re getting when using a standard Play router. Lagom is probably using a different technique for routing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

urlencoded Forward slash is breaking URL - Stack Overflow
I am using urlencode() while preparing the search URL and urldecode() while reading the search URL. Problem. Only the forward slash character is ......
Read more >
Passing a parameter with slashes to the REST call
I need to pass a parameter string that contains slashes to a REST call. I tried URL encoding, or making URL map to...
Read more >
EXPLOITING URL PARSERS: THE GOOD, BAD, AND ...
The confusion in URL parsing can cause unexpected behavior in the software ... scheme confusion, slashes confusion, backslash confusion, URL encoded.
Read more >
Scala Routing - 2.8.x - Play Framework
Unlike other pattern types, path segments are automatically URI-decoded in the route, before being passed to your controller, and encoded in the reverse...
Read more >
encodeURI() - JavaScript - MDN Web Docs
The encodeURI() function encodes a URI by replacing each instance of ... do not encode any valid Unicode character, they cause encodeURI() ...
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