quarkusio/quarkus · error · SecurityException

Invalid workspace path: ${uriString}

Error message

Invalid workspace path: ${uriString}

What it means

Dev UI workspace actions confine file operations to the project root. resolveWorkspacePath parses the client URI and canonicalizes both root and target; if URI creation fails (malformed URI, non-file scheme such as http:, or a path that cannot be safely canonicalized due to I/O errors), it throws SecurityException with 'Invalid workspace path'. This rejects unsafe or unparseable inputs before any file access.

Source

Thrown at extensions/devui/deployment/src/main/java/io/quarkus/devui/deployment/menu/WorkspaceProcessor.java:363

    /**
     * Resolve a client supplied path URI and make sure it stays confined to the project root.
     * The workspace operations are only meant to act on files inside the user's project, so any
     * path (including ones using {@code ..} or symlinks) that resolves outside the root is rejected.
     */
    private static Path resolveWorkspacePath(Path rootPath, String uriString) {
        if (uriString == null) {
            throw new SecurityException("No workspace path provided");
        }

        Path root;
        Path resolved;
        try {
            root = toCanonicalPath(rootPath);
            resolved = toCanonicalPath(Paths.get(URI.create(uriString)));
        } catch (IllegalArgumentException | FileSystemNotFoundException | IOException e) {
            // Malformed URI, a non-file scheme or a path we cannot safely canonicalize: reject it.
            throw new SecurityException("Invalid workspace path: " + uriString);
        }

        if (!resolved.startsWith(root)) {
            throw new SecurityException("Path is outside the project root: " + resolved);
        }
        return resolved;
    }

    /**
     * Normalize a path to an absolute form with symlinks resolved. The file itself may not exist
     * yet (e.g. when creating a new workspace item), so symlinks are only resolved on the nearest
     * existing ancestor to prevent a symlinked directory from escaping the root. If the real path
     * cannot be determined the {@link IOException} is propagated so the caller can fail closed
     * rather than fall back to an unresolved (potentially escaping) path.
     */
    private static Path toCanonicalPath(Path path) throws IOException {
        Path absolute = path.toAbsolutePath().normalize();
        Path existing = absolute;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Send a properly formed file URI: Paths.get(...).toUri().toString() on the client side.
  2. Percent-encode spaces and special characters in the URI.
  3. Use only file-scheme URIs on local filesystems the dev-mode process can access.
  4. Ensure the path's filesystem is available (mounted) before invoking the action.

Example fix

// before
String uri = "/home/user/project/src/App.java"; // not a URI

// after
String uri = java.nio.file.Paths.get("/home/user/project/src/App.java").toUri().toString();
Defensive patterns

Strategy: try-catch

Validate before calling

URI uri;
try { uri = new URI(candidate); } catch (URISyntaxException e) {
    throw new IllegalArgumentException("Not a valid URI: " + candidate, e);
}
if (!"file".equals(uri.getScheme())) throw new IllegalArgumentException("Only file: URIs are supported");

Try / catch

try { Path p = resolveWorkspacePath(root, uriString); ... }
catch (SecurityException e) {
    if (e.getMessage().startsWith("Invalid workspace path")) {
        ui.showError("Send a canonical file: URI, e.g. Paths.get(path).toUri()");
    } else throw e;
}

Prevention

When it happens

Trigger: Calling a workspace action with uriString that is not a valid URI (illegal characters, spaces), uses a non-file scheme (http://, jar:), or whose Path canonicalization (toCanonicalPath) throws IllegalArgumentException, FileSystemNotFoundException, or IOException.

Common situations: Passing a raw filesystem path ('/home/user/file.java') instead of a file: URI; URL-unsafe characters not percent-encoded; pointing at a non-file filesystem; network filesystem issues causing I/O failures during canonicalization.

Related errors


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