quarkusio/quarkus · error · java.lang.RuntimeException

Failed to translate

Error message

Failed to translate 

What it means

PathVisit.getUrl() converts the visited path to a URL via Path.toUri().toURL(). MalformedURLException is rethrown as a RuntimeException including the URI and target type. For file paths this practically never fails; it indicates a malformed/unexpected URI for the visited resource.

Source

Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/PathVisit.java:43

     *
     * The returned path is granted to exist in the underlying file system (unless it was deleted by a parallel process or
     * thread) and therefore it can be used for I/O operations straight away without further resolving, e.g. against
     * {@link #getRoot()}
     *
     * @return path being visited
     */
    Path getPath();

    /**
     * {@link java.net.URL} that can be used to read the content of the path.
     *
     * @return URL that can be used to read the content of the path
     */
    default URL getUrl() {
        try {
            return getPath().toUri().toURL();
        } catch (MalformedURLException e) {
            throw new RuntimeException("Failed to translate " + getPath().toUri() + " to " + URL.class.getName(), e);
        }
    }

    /**
     * Visited class path resource name.
     *
     * @return visited resource name
     */
    default String getResourceName() {
        return getRelativePath("/");
    }

    /**
     * Path relative to the root of the tree as a string with {@code /} as a path element separator.
     * This method calls {@link #getRelativePath(String)} passing {@code /} as an argument.
     *
     * @return path relative to the root of the tree as a string with {@code /} as a path element separator
     */

View on GitHub (pinned to e1c734241f)

Solutions

  1. Inspect the URI in the message for illegal characters and fix how the path was constructed (encode spaces/special chars)
  2. Prefer reading content via OpenablePathTree/open() streams instead of getUrl()
  3. Report upstream with the exact path if a standard path tree produced it

Example fix

// before
URL url = visit.getUrl();
// after
try (InputStream in = Files.newInputStream(visit.getPath())) { /* read */ }
Defensive patterns

Strategy: try-catch

Validate before calling

try { visit.getPath().toUri().toURL(); } catch (MalformedURLException e) { /* fall back to stream access */ }

Try / catch

try { URL url = visit.getUrl(); } catch (RuntimeException e) { if (e.getMessage().startsWith("Failed to translate")) { readViaStream(visit.getPath()); } else { throw e; } }

Prevention

When it happens

Trigger: Calling getUrl() on a PathVisit whose path cannot be translated to a valid URL — typically only when the URI is malformed (illegal characters in scheme/path) or a custom FileSystem provider produces a non-convertible URI.

Common situations: Paths with characters that corrupt the URI (spaces, unencoded special chars) on unusual filesystems; custom jar/jandex filesystem providers; rarely hit for plain files.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/b5552f28e1180699. Report an issue: GitHub.