{"record":{"id":"31e41ffdc200941d","repo":"prestodb/presto","slug":"error-preprocessing-query","errorCode":null,"errorMessage":"Error preprocessing query: ","messagePattern":"Error preprocessing query: ","errorType":"exception","errorClass":"QueryPreprocessorException","httpStatus":null,"severity":"error","filePath":"presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java","lineNumber":166,"sourceCode":"                    // wait for process to finish\n                    exitCode = process.waitFor();\n                }\n                finally {\n                    process.destroyForcibly();\n                    if (writeOutput != null) {\n                        writeOutput.cancel(true);\n                    }\n                }\n            }\n            catch (QueryPreprocessorException e) {\n                throw e;\n            }\n            catch (InterruptedException e) {\n                Thread.currentThread().interrupt();\n                throw new QueryPreprocessorException(\"Interrupted while preprocessing query\");\n            }\n            catch (Throwable e) {\n                throw new QueryPreprocessorException(\"Error preprocessing query: \" + e.getMessage(), e);\n            }\n\n            // check we got a valid exit code\n            if (exitCode != 0) {\n                Optional<String> errorMessage = tryGetFutureValue(readStderr, 100, MILLISECONDS)\n                        .flatMap(value -> Optional.ofNullable(emptyToNull(value.trim())));\n\n                throw new QueryPreprocessorException(\"Query preprocessor exited \" + exitCode +\n                        errorMessage.map(message1 -> \"\\n===\\n\" + message1 + \"\\n===\").orElse(\"\"));\n            }\n            return result;\n        });\n\n        try {\n            return task.get(timeout.toMillis(), MILLISECONDS);\n        }\n        catch (InterruptedException e) {\n            Thread.currentThread().interrupt();","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java#L148-L184","documentation":"QueryPreprocessorException thrown by the CLI's internal query preprocessor when any Throwable escapes the preprocessor execution. The message wraps the underlying exception's getMessage() (may be empty), and the original is attached as the cause. The preprocessor runs a user-supplied command that rewrites the SQL text before it is sent to the server.","triggerScenarios":"Running the Presto CLI with --preprocessor-command where the external preprocessor process throws/returns an error; any RuntimeException or Error thrown inside the preprocessor task during preprocessQueryInternal.","commonSituations":"Misconfigured preprocessor script that crashes on certain SQL; preprocessor binary missing/incompatible causing an unexpected exception; JVM errors (OOM) during preprocessing; network/IO exceptions inside the preprocessor pipeline.","solutions":["Inspect the full stack trace: the cause attached to this exception names the real failure.","Run the preprocessor command manually with a sample query to reproduce the failure.","Verify the preprocessor executable exists, is executable, and works with the installed JVM.","Fix or update the preprocessor script; if preprocessing is not needed, remove --preprocessor-command.","Wrap your preprocessor so it exits 0 or produces a clear error message instead of throwing."],"exampleFix":"// before\n./presto --server localhost:8080 --preprocessor-command ./my-flaky-preprocessor.sh\n// after\n./my-flaky-preprocessor.sh < sample.sql  # test first; fix or drop the flag\n./presto --server localhost:8080 --preprocessor-command ./my-fixed-preprocessor.sh","handlingStrategy":"try-catch","validationCode":"// before invoking the CLI\nif [ ! -x \"$PREPROCESSOR_CMD\" ]; then echo \"preprocessor missing: $PREPROCESSOR_CMD\" >&2; exit 1; fi","typeGuard":null,"tryCatchPattern":"try {\n    preprocessQuery(query);\n} catch (QueryPreprocessorException e) {\n    Throwable cause = e.getCause();\n    log.error(\"preprocessor failed\", cause != null ? cause : e);\n    throw e;\n}","preventionTips":["Test the preprocessor command standalone with representative SQL before wiring it into the CLI.","Keep the preprocessor dependency-free and fast.","Remove --preprocessor-command when not needed.","Log the full cause chain, since the top-level message may be empty."],"tags":["cli","query-preprocessing","subprocess"],"backgroundTag":"query-preprocessor-failed","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"}