Skip to content

Windows build fails: InvalidPath due to URL.getPath() in PureJavaTestEngineBodyTest #49

Description

@snytkine

Description

The Windows CI build fails with an InvalidPath error in PureJavaTestEngineBodyTest.fileTypeResolvesExistingTestFixture. The test uses URL.getPath() to construct a Path, which returns a string starting with /D:/... on Windows. Path.of(String) rejects this because the : character at index 3 is illegal when preceded by a /.

Error

PureJavaTestEngineBodyTest.fileTypeResolvesExistingTestFixture:89 » InvalidPath
Illegal char <:> at index 3: /D:/a/api-tester-cli/api-tester-cli/target/test-classes/request-body-1.json

Root Cause

Line 89 of PureJavaTestEngineBodyTest.java:

// BROKEN — URL.getPath() returns "/D:/a/..." on Windows
Path suiteDir = Path.of(getClass().getResource("/request-body-1.json").getPath())
        .getParent();

URL.getPath() returns the path component of the file: URL. On Unix this is fine (the leading / is the filesystem root). On Windows the URL is file:///D:/..., so getPath() returns /D:/... — a string that Path.of(String) cannot parse on Windows.

Every other test in the codebase already uses the correct .toURI() pattern; this was the only outlier.

Fix

Replace getPath() with toURI(), consistent with the rest of the test suite:

// FIXED — Path.of(URI) handles Windows drive letters correctly
Path suiteDir = Path.of(getClass().getResource("/request-body-1.json").toURI())
        .getParent();

The method's throws clause is also widened from IOException to Exception since URL.toURI() throws URISyntaxException, which is not a subtype of IOException.

Affected file

src/test/java/io/github/snytkine/apitester/api_tester_cli/service/PureJavaTestEngineBodyTest.java, line 89

Observed on

Windows runner (windows-latest) in the GraalVM native binary release workflow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions