prestodb/presto · error · IllegalArgumentException

Invalid URI:

Error message

Invalid URI: 

What it means

LocalTempStorage.deserializeStatic() decodes a serialized storage handle as a UTF-8 string and parses it as a URI to rebuild a Path. If the string is not a valid URI it throws IllegalArgumentException 'Invalid URI: ' + uriString. This guards against corrupted or hand-crafted storage handles.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/spiller/LocalTempStorage.java:155

    {
        URI uri = ((LocalTempStorageHandle) storageHandle).getFilePath().toUri();
        return uri.toString().getBytes(UTF_8);
    }

    @Override
    public TempStorageHandle deserialize(byte[] serializedStorageHandle)
    {
        return LocalTempStorage.deserializeStatic(serializedStorageHandle);
    }

    public static LocalTempStorageHandle deserializeStatic(byte[] serializedStorageHandle)
    {
        String uriString = new String(serializedStorageHandle, UTF_8);
        try {
            return new LocalTempStorageHandle(Paths.get(new URI(uriString)));
        }
        catch (URISyntaxException e) {
            throw new IllegalArgumentException("Invalid URI: " + uriString, e);
        }
    }

    @Override
    public List<StorageCapabilities> getStorageCapabilities()
    {
        return ImmutableList.of();
    }

    private static void cleanupOldSpillFiles(Path path)
    {
        try (DirectoryStream<Path> stream = newDirectoryStream(path, SPILL_FILE_GLOB)) {
            stream.forEach(spillFile -> {
                try {
                    log.info("Deleting old spill file: " + spillFile);
                    delete(spillFile);
                }
                catch (Exception e) {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Log/inspect the uriString in the message and re-encode illegal characters (spaces -> %20) or fix the producer of the handle.
  2. Re-run the query without reusing the stale serialized handle; handles are per-storage and should be regenerated.
  3. Ensure both sides use the same Presto version's storage-handle serialization format.
  4. If a custom integration writes handles, URL-encode the path before building the URI string.

Example fix

// before: producer writes raw path with spaces
String uriString = "/spill dir/file"; // URISyntaxException

// after: encode when serializing
String uriString = "/spill%20dir/file"; // valid URI for Paths.get(new URI(uriString))
Defensive patterns

Strategy: validation

Validate before calling

boolean validHandle = (handle == null) || isValidUri(new String(handle, java.nio.charset.StandardCharsets.UTF_8));

static boolean isValidUri(String s) {
    try { new java.net.URI(s); return true; } catch (java.net.URISyntaxException e) { return false; }
}

Type guard

static boolean isValidUri(String s) {
    try { new java.net.URI(s); return true; }
    catch (java.net.URISyntaxException e) { return false; }
}

Try / catch

try {
    storage.deserializeStatic(bytes);
} catch (IllegalArgumentException e) {
    // discard/regenerate the serialized handle rather than reusing it
}

Prevention

When it happens

Trigger: Calling deserializeStatic(byte[]) with bytes that are not a syntactically valid URI — new URI(uriString) throws URISyntaxException — typically from a truncated/corrupted serialized handle, a handle serialized by an incompatible version, or illegal characters (spaces, unencoded symbols) in the path.

Common situations: Serialized exchange/storage handles persisted then replayed across nodes or versions; paths with spaces or special characters not URI-encoded; manual edits to serialized metadata; network truncation of serialized payloads.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/54e3f7c90b6cbb28. Report an issue: GitHub.