{"record":{"id":"54e3f7c90b6cbb28","repo":"prestodb/presto","slug":"invalid-uri","errorCode":null,"errorMessage":"Invalid URI: ","messagePattern":"Invalid URI: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/spiller/LocalTempStorage.java","lineNumber":155,"sourceCode":"    {\n        URI uri = ((LocalTempStorageHandle) storageHandle).getFilePath().toUri();\n        return uri.toString().getBytes(UTF_8);\n    }\n\n    @Override\n    public TempStorageHandle deserialize(byte[] serializedStorageHandle)\n    {\n        return LocalTempStorage.deserializeStatic(serializedStorageHandle);\n    }\n\n    public static LocalTempStorageHandle deserializeStatic(byte[] serializedStorageHandle)\n    {\n        String uriString = new String(serializedStorageHandle, UTF_8);\n        try {\n            return new LocalTempStorageHandle(Paths.get(new URI(uriString)));\n        }\n        catch (URISyntaxException e) {\n            throw new IllegalArgumentException(\"Invalid URI: \" + uriString, e);\n        }\n    }\n\n    @Override\n    public List<StorageCapabilities> getStorageCapabilities()\n    {\n        return ImmutableList.of();\n    }\n\n    private static void cleanupOldSpillFiles(Path path)\n    {\n        try (DirectoryStream<Path> stream = newDirectoryStream(path, SPILL_FILE_GLOB)) {\n            stream.forEach(spillFile -> {\n                try {\n                    log.info(\"Deleting old spill file: \" + spillFile);\n                    delete(spillFile);\n                }\n                catch (Exception e) {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/spiller/LocalTempStorage.java#L137-L173","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Log/inspect the uriString in the message and re-encode illegal characters (spaces -> %20) or fix the producer of the handle.","Re-run the query without reusing the stale serialized handle; handles are per-storage and should be regenerated.","Ensure both sides use the same Presto version's storage-handle serialization format.","If a custom integration writes handles, URL-encode the path before building the URI string."],"exampleFix":"// before: producer writes raw path with spaces\nString uriString = \"/spill dir/file\"; // URISyntaxException\n\n// after: encode when serializing\nString uriString = \"/spill%20dir/file\"; // valid URI for Paths.get(new URI(uriString))","handlingStrategy":"validation","validationCode":"boolean validHandle = (handle == null) || isValidUri(new String(handle, java.nio.charset.StandardCharsets.UTF_8));\n\nstatic boolean isValidUri(String s) {\n    try { new java.net.URI(s); return true; } catch (java.net.URISyntaxException e) { return false; }\n}","typeGuard":"static boolean isValidUri(String s) {\n    try { new java.net.URI(s); return true; }\n    catch (java.net.URISyntaxException e) { return false; }\n}","tryCatchPattern":"try {\n    storage.deserializeStatic(bytes);\n} catch (IllegalArgumentException e) {\n    // discard/regenerate the serialized handle rather than reusing it\n}","preventionTips":["URI-encode paths (spaces, special characters) when serializing handles","Never hand-edit serialized storage handles","Keep serialization format/version consistent across cluster nodes"],"tags":["serialization","uri","storage-handle","presto"],"backgroundTag":"invalid-uri","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}