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.

IllegalArgumentException path must exist when the path has spaces and the URI has replaced the space with %20 url encoded

See original GitHub issue

When the path, in my case project path, has spaces. the below error observed

[ERROR] setUpClass(common.TestRunner)  Time elapsed: 2.057 s  <<< FAILURE!
java.lang.IllegalArgumentException: path must exist: /Users/edmundofigueroa/projects/test test test/automation-testcases-mobile/features

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   TestRunner>AbstractTestNGCucumberTests.setUpClass:27 » IllegalArgument path mu...
[INFO] 
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO] 
[ERROR] There are test failures.

using cucumber-testng 7.6.1

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>7.6.1</version>
        </dependency>

In debugging mode, I could see that the exception is thrown in cucumber-core-7.6.0.jar,

package io.cucumber.core.resource
ResourceScanner class > scanForResourcesUri(URI classpathResourceUri)
// classpathResourceUri = file:/Users/edmundofigueroa/projects/test%20test%20test/automation-testcases-mobile/features
image

the spaces are replaced by %20 which is url encoded space

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mpkorstanjecommented, Sep 6, 2022

But I consider this as a bug as for the filesystem path, as far as I know, the path can’t contain the symbol %. While in this case, the path was encoded as an url, %20 is url encoded for a blank space.

I believe you are mistaken here. Note that scanForResourcesUri takes a URI as an argument. Spaces are not legal characters in a URI and so must be encoded:

https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/net/URI.html

An illegal character is quoted simply by encoding it. The space character, for example, is quoted by replacing it with “%20”. UTF-8 contains US-ASCII, hence for US-ASCII characters this transformation has exactly the effect required by RFC 2396.

So while your project may not work with spaces in the path, it may not work for a different reason.

Now I’ve tried to reproduce your project but unfortunately I seem to be unable to. Could you please provide a minimal reproducer in the form of a github repo? You can use https://github.com/cucumber/cucumber-java-skeleton as a starting point.

0reactions
zgordon02commented, Nov 16, 2022

@figuedmundo what was your resolution to this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Illegal character in path at index 16 [duplicate] - Stack Overflow
I'd say it doesn't like the space in the path. You can percent encode special characters like spaces. Replace it with a %20...
Read more >
URL from string with spaces in it | Apple Developer Forums
You should escape the spaces. To do that, you can either change the spaces to "%20" or "+". ... You can shrink the...
Read more >
HttpUrl - OkHttp - Square Open Source
Unlike host, port, path, and query the fragment is not sent to the webserver: it's private to the client. Encoding¶. Each component must...
Read more >
Space in URL is getting encoded differently ... - Microsoft Learn
We are navigating to URL and URL contains a space is shown as below: ... machine 1: edge browser url showed www.google.com%20www.oracle.com
Read more >
URI (Java Platform SE 7 ) - Oracle Help Center
A hierarchical URI always has a path (though it may be empty) and a ... The space character, for example, is quoted by...
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