{"record":{"id":"1bb374eef6a3b2fa","repo":"apache/druid","slug":"could-not-write-value-s-to-field-s","errorCode":null,"errorMessage":"Could not write value [%s] to field [%s]","messagePattern":"Could not write value \\[(.+?)\\] to field \\[(.+?)\\]","errorType":"exception","errorClass":"QueryDriver.RequestError","httpStatus":null,"severity":"error","filePath":"extensions-contrib/grpc-query/src/main/java/org/apache/druid/grpc/server/ProtobufWriter.java","lineNumber":120,"sourceCode":"          message.getClass()\n      );\n    }\n    final Method method = methods.computeIfAbsent(\"setField\", k -> {\n      try {\n        return rowBuilder\n            .getClass()\n            .getMethod(\n                \"setField\", new Class<?>[]{Descriptors.FieldDescriptor.class, Object.class});\n      }\n      catch (NoSuchMethodException e) {\n        throw new RuntimeException(e);\n      }\n    });\n    try {\n      method.invoke(rowBuilder, fieldDescriptor, value);\n    }\n    catch (IllegalAccessException | InvocationTargetException e) {\n      throw new QueryDriver.RequestError(\n          \"Could not write value [%s] to field [%s]\",\n          value,\n          name\n      );\n    }\n  }\n\n  @Override\n  public void writeRowEnd() throws IOException\n  {\n    Message rowMessage = rowBuilder.build();\n    rowMessage.writeDelimitedTo(outputStream);\n  }\n\n  @Override\n  public void writeResponseEnd()\n  {\n  }","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/grpc-query/src/main/java/org/apache/druid/grpc/server/ProtobufWriter.java#L102-L138","documentation":"ProtobufWriter.writeRowField uses reflection to call Builder.setField, and the reflective invocation failed (IllegalAccessException or the underlying setter threw, e.g. type mismatch). The value produced for a column cannot be written into the corresponding protobuf field, so a QueryDriver.RequestError is raised to surface a result-encoding failure to the client.","triggerScenarios":"Thrown at extensions-contrib/grpc-query/src/main/java/org/apache/druid/grpc/server/ProtobufWriter.java:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped InvocationTargetException for the setter's real failure — usually a value/field type mismatch.","Ensure the SQL column types are compatible with the declared .proto field types (e.g. int64 vs int32, string vs bytes).","Handle nulls and unsupported Java types before invoking setField.","Catch QueryDriver.RequestError at the server layer to return a descriptive gRPC error status."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}