{"record":{"id":"5bb3d72990569487","repo":"prestodb/presto","slug":"query-preprocessor-exited","errorCode":null,"errorMessage":"Query preprocessor exited ","messagePattern":"Query preprocessor exited ","errorType":"exception","errorClass":"QueryPreprocessorException","httpStatus":null,"severity":"error","filePath":"presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java","lineNumber":174,"sourceCode":"                }\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();\n            throw new QueryPreprocessorException(\"Interrupted while preprocessing query\");\n        }\n        catch (ExecutionException e) {\n            Throwable cause = e.getCause();\n            propagateIfPossible(cause, QueryPreprocessorException.class);\n            throw new QueryPreprocessorException(\"Error preprocessing query: \" + cause.getMessage(), cause);\n        }\n        catch (TimeoutException e) {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java#L156-L192","documentation":"QueryPreprocessorException thrown when the external preprocessor process terminates with a non-zero exit code. The CLI waits for the process, reads its stderr (with a 100ms timeout), and appends any captured stderr to the message to explain why the process failed.","triggerScenarios":"The command given via --preprocessor-command exits with a status != 0; any crash, shell error, or explicit exit failure in the preprocessor script while preprocessing a query.","commonSituations":"Preprocessor script references a missing interpreter (bad shebang); script hits an error on specific SQL syntax; missing dependencies in the preprocessor environment; preprocessor rejects the query text by design.","solutions":["Read the stderr block (=== ... ===) appended to the message; it usually states the process failure.","Run the preprocessor command manually against the same SQL to see the error.","Fix the script's bugs/missing dependencies and ensure it exits 0 on success.","Check the shebang line and PATH inside the environment the CLI runs in.","If the preprocessor intentionally rejects queries, adjust its exit/protocol handling to match the expected contract."],"exampleFix":"// before (script exits non-zero on heredoc quoting bug)\n#!/usr/bin/env python3\nmain(sys.argv[1:])\n// after\n#!/usr/bin/env python3\nif __name__ == \"__main__\":\n    sys.exit(main(sys.argv[1:]) or 0)","handlingStrategy":"try-catch","validationCode":"// dry-run the preprocessor and check its exit code\nyour-preprocessor.sh < sample.sql >/dev/null; echo $?  # must be 0","typeGuard":null,"tryCatchPattern":"try {\n    preprocessQuery(query);\n} catch (QueryPreprocessorException e) {\n    if (e.getMessage().startsWith(\"Query preprocessor exited\")) {\n        log.error(\"preprocessor process failed; stderr captured in message: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Make the preprocessor exit 0 on success and print errors to stderr.","Fix shebangs and interpreter availability in the execution environment.","Add a self-check mode to the preprocessor script.","Version-pin and smoke-test the preprocessor in CI."],"tags":["cli","query-preprocessing","exit-code","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"}