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.

Invalid Malformed URL

See original GitHub issue

The path of a URL contains a colon symbol which is causing the call to fail.

Using version com.squareup.retrofit2:retrofit:2.5.0

Code:

public interface ClientApi {
    @PUT("user:email={email}/login")
    Call<ResponseBody> login(@Path("email") String email, @Body String pass);

    @PUT("./user:email={email}/login")
    Call<ResponseBody> loginRelative(@Path("email") String email, @Body String pass);
...

Regular path Stack trace:

Caused by: java.lang.IllegalArgumentException: Malformed URL. Base: https://test.com/restapi/, Relative: user:email=me@test.com/login
        at retrofit2.RequestBuilder.get(RequestBuilder.java:221)
        at retrofit2.RequestFactory.create(RequestFactory.java:111)
        at retrofit2.OkHttpCall.createRawCall(OkHttpCall.java:190)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:173)
        at Service.login(Service.java:38)

Think the code needs to treat the relative portion of the URL like an absolute URL when parsing.

Relative path Using a retaliative path annotation ./ does not solve this issue. Stack trace:

Caused by: java.lang.IllegalArgumentException: @Path parameters shouldn't perform path traversal ('.' or '..'):
        at retrofit2.RequestBuilder.addPathParam(RequestBuilder.java:113)
        at retrofit2.ParameterHandler$Path.apply(ParameterHandler.java:99)
        at retrofit2.RequestFactory.create(RequestFactory.java:108)
        at retrofit2.OkHttpCall.createRawCall(OkHttpCall.java:190)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:173)

Bug report unit test https://gist.github.com/nathancassano/f675e2fd1c64d4b6002afea37bf5fee4

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
JakeWhartoncommented, Apr 16, 2019

Yeah this should be allowed.

cc @swankjesse

1reaction
thezukkinocommented, Jan 7, 2020

Is there any news about this issue? This problem causes a version lock to 2.4.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Invalid Hyperlink: Malformed URI is embedded as a
Invalid Hyperlink: Malformed URI is embedded as a hyperlink in the document. clientRequestId · Press Alt+F11 to open the VB editor. · Add...
Read more >
Malformed URL - Common causes and quick fixes - Opster
This guide will help you check for common problems that cause the log ” malformed URL ” to appear.
Read more >
INVALID HYPERLINK MALFORMED URL IS EMBEDDED AS ...
Video Agenda: INVALID HYPERLINK: MALFORMED URL IS EMBEDDED AS HYPERLINK IN THE DOCUMENT ERROR IN UIPATHInvalid Hyperlink Error in UiPathRead ...
Read more >
Why am I not getting a MalformedURLException on incorrect ...
Your example is not a malformed URL. The TLD does not exist, yes (at least publicly), but it's still a valid format.
Read more >
What is a MalformedURLException and how to fix it in java?
The only Solution for this is to make sure that the url you have passed is legal, with a proper protocol. The best...
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