{"record":{"id":"2ea323bd45b10fb0","repo":"prestodb/presto","slug":"only-sql-payload-type-is-allowed","errorCode":null,"errorMessage":"Only [SQL] Payload type is allowed: ","messagePattern":"Only \\[SQL\\] Payload type is allowed: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotProxyGrpcRequestBuilder.java","lineNumber":105,"sourceCode":"    public PinotProxyGrpcRequestBuilder addExtraMetadata(Map<String, String> extraMetadata)\n    {\n        this.extraMetadata.putAll(extraMetadata);\n        return this;\n    }\n\n    public PinotProxyGrpcRequestBuilder setSegments(List<String> segments)\n    {\n        this.segments = segments;\n        return this;\n    }\n\n    public Server.ServerRequest build()\n    {\n        if (payloadType == null || segments.isEmpty()) {\n            throw new PinotException(PinotErrorCode.PINOT_INVALID_SEGMENT_QUERY_GENERATED, Optional.empty(), \"Query and segmentsToQuery must be set\");\n        }\n        if (!payloadType.equals(CommonConstants.Query.Request.PayloadType.SQL)) {\n            throw new RuntimeException(\"Only [SQL] Payload type is allowed: \" + payloadType);\n        }\n        Map<String, String> metadata = new HashMap<>();\n        metadata.put(CommonConstants.Query.Request.MetadataKeys.REQUEST_ID, Integer.toString(requestId));\n        metadata.put(CommonConstants.Query.Request.MetadataKeys.BROKER_ID, brokerId);\n        metadata.put(CommonConstants.Query.Request.MetadataKeys.ENABLE_TRACE, Boolean.toString(enableTrace));\n        metadata.put(CommonConstants.Query.Request.MetadataKeys.ENABLE_STREAMING, Boolean.toString(enableStreaming));\n        metadata.put(CommonConstants.Query.Request.MetadataKeys.PAYLOAD_TYPE, payloadType);\n        if (this.hostName != null) {\n            metadata.put(KEY_OF_PROXY_GRPC_FORWARD_HOST, this.hostName);\n        }\n        if (this.port > 0) {\n            metadata.put(KEY_OF_PROXY_GRPC_FORWARD_PORT, String.valueOf(this.port));\n        }\n        extraMetadata.forEach((k, v) -> metadata.put(k, v));\n        return Server.ServerRequest.newBuilder()\n            .putAllMetadata(metadata)\n            .setSql(sql)\n            .addAllSegments(segments)","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotProxyGrpcRequestBuilder.java#L87-L123","documentation":"After the null/empty check, PinotProxyGrpcRequestBuilder.build() enforces that the payload type equals CommonConstants.Query.Request.PayloadType.SQL; any other payload type causes a plain RuntimeException 'Only [SQL] Payload type is allowed: <type>'. The Presto Pinot gRPC proxy path only speaks SQL payloads, so protobuf/other payload modes are rejected.","triggerScenarios":"Setting the builder's payload type to something other than SQL (e.g. PAYLOAD_PROTOBUF or an internal type) before calling build(), typically when reusing Pinot's gRPC request classes for a non-SQL execution path.","commonSituations":"Integrating with Pinot's multi-stage or protobuf-based execution APIs via the Presto connector's builder; copy-pasted code from Pinot examples that use non-SQL payloads; version drift where a payload type constant changed.","solutions":["Set the payload type to CommonConstants.Query.Request.PayloadType.SQL before build().","If you need non-SQL payloads, do not use this Presto connector builder — use Pinot's native gRPC client APIs directly.","Audit the code path that sets payloadType for a wrong constant or stale enum value after a Pinot dependency upgrade.","Handle/replace the RuntimeException with a typed exception at the call site if you control the builder usage."],"exampleFix":"// before\nbuilder.setPayloadType(CommonConstants.Query.Request.PayloadType.PAYLOAD_PROTOBUF);\n\n// after\nbuilder.setPayloadType(CommonConstants.Query.Request.PayloadType.SQL);","handlingStrategy":"validation","validationCode":"// Enforce SQL payload before build():\ncheckArgument(CommonConstants.Query.Request.PayloadType.SQL.equals(payloadType),\n    \"Only SQL payload supported, got %s\", payloadType);","typeGuard":"boolean isSqlPayload(Object payloadType) {\n    return CommonConstants.Query.Request.PayloadType.SQL.equals(payloadType);\n}","tryCatchPattern":"try {\n    Server.ServerRequest req = builder.build();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Only [SQL] Payload type\")) {\n        // fix builder config or use Pinot native gRPC client for non-SQL payloads\n    } else throw e;\n}","preventionTips":["Hardcode PayloadType.SQL when using the Presto connector's gRPC path","Do not reuse this builder for Pinot multi-stage/protobuf execution","Re-check payload constants after upgrading the Pinot dependency"],"tags":["pinot","grpc","payload-type","validation"],"backgroundTag":"invalid-request-state","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"}