{"record":{"id":"4b720c59403bdbdf","repo":"apache/druid","slug":"unsupported-query-result-format","errorCode":null,"errorMessage":"Unsupported query result format: ","messagePattern":"Unsupported query result format: ","errorType":"exception","errorClass":"QueryDriver.RequestError","httpStatus":null,"severity":"error","filePath":"extensions-contrib/grpc-query/src/main/java/org/apache/druid/grpc/server/QueryDriver.java","lineNumber":686,"sourceCode":"        writer = new GrpcSqlResultFormatWriter(\n            ResultFormat.ARRAY.createFormatter(out, jsonMapper),\n            rowTransformer\n        );\n        break;\n      case JSON_ARRAY_LINES:\n        writer = new GrpcSqlResultFormatWriter(\n            ResultFormat.ARRAYLINES.createFormatter(out, jsonMapper),\n            rowTransformer\n        );\n        break;\n      case PROTOBUF_INLINE:\n        writer = new GrpcSqlResultFormatWriter(\n            new ProtobufWriter(out, getProtobufClass(request)),\n            rowTransformer\n        );\n        break;\n      default:\n        throw new RequestError(\"Unsupported query result format: \" + request.getResultFormat().name());\n    }\n    GrpcResultsAccumulator accumulator = new GrpcResultsAccumulator(writer);\n    accumulator.push(result);\n    return ByteString.copyFrom(out.toByteArray());\n  }\n\n  private ByteString encodeNativeResults(\n      final QueryRequest request,\n      final Sequence<Object[]> result,\n      final RowSignature rowSignature\n  ) throws IOException\n  {\n    // Accumulate the results as a byte array.\n    ByteArrayOutputStream out = new ByteArrayOutputStream();\n    GrpcResultWriter writer;\n    final String timeFieldName = request.getContextMap().getOrDefault(TIME_FIELD_KEY, \"time\");\n    final List<String> skipColumns = request.getSkipColumnsList();\n    final List<String> timeColumns = request.getTimeColumnsList();","sourceCodeStart":668,"sourceCodeEnd":704,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/grpc-query/src/main/java/org/apache/druid/grpc/server/QueryDriver.java#L668-L704","documentation":"encodeSqlResults maps the request's result format to a GrpcSqlResultFormatWriter. The recognized formats are handled in a switch; anything else (an unknown or unhandled ResultFormat enum value) reaches the default branch and throws RequestError(\"Unsupported query result format: ...\"). The request's requested output format is not implemented by the gRPC extension for SQL queries.","triggerScenarios":"Sending a QueryRequest with resultFormat set to an enum value the extension's encodeSqlResults switch does not cover (e.g. a newly added protobuf ResultFormat value, or a format only supported for native queries).","commonSituations":"Client and server protobuf definitions are out of sync (client built from a newer .proto adds a new ResultFormat); a constant copied from another API; fat-fingered enum assignment in generated client code.","solutions":["Use a supported result format value from the extension's switch (e.g. the default/protobuf writer format) in the QueryRequest.","Regenerate client stubs from the same .proto version the server was built with so enum values match.","Check the extension source/docs for the exact set of supported ResultFormat values for SQL results.","If a new format is required, add a case to the switch and implement a corresponding GrpcResultFormatWriter, then rebuild the server."],"exampleFix":"// before\nrequest.setResultFormat(ResultFormat.CSV);\n// after\nrequest.setResultFormat(ResultFormat.FORMAT_DEFAULT); // a format encodeSqlResults handles","handlingStrategy":"validation","validationCode":"// Only send formats the server switch handles\njava.util.Set<ResultFormat> SUPPORTED = java.util.Set.of(ResultFormat.FORMAT_DEFAULT /* + others per extension */);\nif (!SUPPORTED.contains(request.getResultFormat())) {\n  throw new IllegalArgumentException(\"unsupported result format: \" + request.getResultFormat());\n}","typeGuard":null,"tryCatchPattern":"try {\n  return stub.query(req);\n} catch (StatusRuntimeException e) {\n  if (e.getStatus().getDescription() != null && e.getStatus().getDescription().startsWith(\"Unsupported query result format\")) {\n    req = req.toBuilder().setResultFormat(ResultFormat.FORMAT_DEFAULT).build();\n    return stub.query(req);\n  }\n  throw e;\n}","preventionTips":["Pin client-generated protobuf stubs to the server extension's proto version.","Centralize result-format selection in one constant/helper in client code.","Verify supported formats against the deployed extension's source before using a new enum value.","Add a smoke test per result format against a dev server."],"tags":["grpc","sql","result-format","enum"],"backgroundTag":"unsupported-enum-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}