{"record":{"id":"5fa9ba768868d3a6","repo":"prestodb/presto","slug":"invalid-arguments-5fa9ba","errorCode":"INVALID_ARGUMENTS","errorMessage":"Failed to get optimized expressions from sidecar.","messagePattern":"Failed to get optimized expressions from sidecar\\.","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/expressions/NativeSidecarExpressionInterpreter.java","lineNumber":126,"sourceCode":"\n        Map<RowExpression, RowExpression> result = new IdentityHashMap<>();\n        for (int i = 0; i < rowExpressionOptimizationResults.size(); i++) {\n            result.put(originalExpressions.get(i), rowExpressionOptimizationResults.get(i).getOptimizedExpression());\n        }\n        return unmodifiableMap(result);\n    }\n\n    public List<RowExpressionOptimizationResult> optimize(ConnectorSession session, ExpressionOptimizer.Level level, List<RowExpression> resolvedExpressions)\n    {\n        List<RowExpressionOptimizationResult> optimizedExpressions;\n        long start = System.nanoTime();\n        try {\n            optimizedExpressions = httpClient.execute(\n                    getSidecarRequest(session, level, resolvedExpressions),\n                    createJsonResponseHandler(rowExpressionOptimizationResultJsonCodec));\n        }\n        catch (Exception e) {\n            throw new PrestoException(INVALID_ARGUMENTS, \"Failed to get optimized expressions from sidecar.\", e);\n        }\n        finally {\n            Duration duration = new Duration(System.nanoTime() - start, TimeUnit.NANOSECONDS);\n            latency.add(duration);\n            log.debug(\"queryId=%s, expression optimization latencyMs=%d\", session.getQueryId(), duration.toMillis());\n        }\n        return optimizedExpressions;\n    }\n\n    @Managed\n    @Nested\n    public TimeStat getLatency()\n    {\n        return latency;\n    }\n\n    private Request getSidecarRequest(ConnectorSession session, Level level, List<RowExpression> resolvedExpressions)\n    {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/expressions/NativeSidecarExpressionInterpreter.java#L108-L144","documentation":"This PrestoException (INVALID_ARGUMENTS) is thrown by NativeSidecarExpressionInterpreter.optimize when the HTTP call to the native sidecar expression-optimization endpoint fails for any reason — connection errors, timeouts, non-2xx responses, or deserialization failures of the response. The original exception is attached as the cause; the message is generic.","triggerScenarios":"httpClient.execute for the sidecar request throws: sidecar service down/unscaled, DNS or network failure, request timeout, sidecar returning 5xx/4xx, or response JSON not matching rowExpressionOptimizationResultJsonCodec.","commonSituations":"Sidecar deployment not running or autoscaled to zero; wrong sidecar URI/port in config; network/security-group blocking worker→sidecar traffic; version skew producing incompatible response schema.","solutions":["Check the cause exception to distinguish connection refused vs timeout vs HTTP error","Verify the sidecar service is healthy and reachable (health endpoint, service discovery, URI config)","Confirm sidecar and coordinator/native versions return compatible response schema","Add/rely on retry with backoff for transient network failures, then fall back to Java expression interpreter"],"exampleFix":"// before: single hard call\noptimizedExpressions = httpClient.execute(request, handler);\n// after: caller-level fallback\ntry {\n    return sidecarInterpreter.optimize(session, level, expressions);\n} catch (PrestoException e) {\n    log.warn(e, \"sidecar optimization failed; falling back to Java\");\n    return javaInterpreter.optimize(session, level, expressions);\n}","handlingStrategy":"retry","validationCode":"// preflight: verify sidecar reachability before first use\ntry (Socket s = new Socket()) {\n  s.connect(new InetSocketAddress(sidecarHost, sidecarPort), 2000); // throws if unreachable\n}","typeGuard":null,"tryCatchPattern":"try {\n  return interpreter.optimize(session, level, expressions);\n} catch (PrestoException e) {\n  if (isTransient(e.getCause())) { // IOException, timeout\n    return retryWithBackoff(() -> interpreter.optimize(session, level, expressions), 3);\n  }\n  // persistent failure: fall back to Java expression interpreter\n  return javaInterpreter.optimize(session, level, expressions);\n}","preventionTips":["Monitor sidecar health endpoint and alert on unreachability","Configure sensible HTTP connect/read timeouts and retries in the sidecar client","Verify sidecar URI/port and network/security-group rules between workers and sidecar","Keep sidecar response schema compatible with the plugin codec (version-locked upgrades)","Fall back to the Java expression interpreter on persistent sidecar failures"],"tags":["network","http","native-sidecar","service-unavailable"],"backgroundTag":"sidecar-request-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"}