{"record":{"id":"74b80d6f5f914752","repo":"apache/hadoop","slug":"request-must-contain-identifier","errorCode":null,"errorMessage":"Request must contain identifier","messagePattern":"Request must contain identifier","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/protocolPB/GenericRefreshProtocolServerSideTranslatorPB.java","lineNumber":53,"sourceCode":"    GenericRefreshProtocolPB {\n\n  private final GenericRefreshProtocol impl;\n\n  public GenericRefreshProtocolServerSideTranslatorPB(\n      GenericRefreshProtocol impl) {\n    this.impl = impl;\n  }\n\n  @Override\n  public GenericRefreshResponseCollectionProto refresh(\n      RpcController controller, GenericRefreshRequestProto request)\n      throws ServiceException {\n    try {\n      List<String> argList = request.getArgsList();\n      String[] args = argList.toArray(new String[argList.size()]);\n\n      if (!request.hasIdentifier()) {\n        throw new ServiceException(\"Request must contain identifier\");\n      }\n\n      Collection<RefreshResponse> results = impl.refresh(request.getIdentifier(), args);\n\n      return pack(results);\n    } catch (IOException e) {\n      throw new ServiceException(e);\n    }\n  }\n\n  // Convert a collection of RefreshResponse objects to a\n  // RefreshResponseCollection proto\n  private GenericRefreshResponseCollectionProto pack(\n    Collection<RefreshResponse> responses) {\n    GenericRefreshResponseCollectionProto.Builder b =\n      GenericRefreshResponseCollectionProto.newBuilder();\n\n    for (RefreshResponse response : responses) {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/protocolPB/GenericRefreshProtocolServerSideTranslatorPB.java#L35-L71","documentation":"GenericRefreshProtocolServerSideTranslatorPB is the server-side translator for the generic refresh protocol used by 'hdfs dfsadmin -refresh'. The protobuf GenericRefreshRequest must carry the refresh handler identifier so the server can route the request to the registered RefreshHandler; a request with the identifier field absent fails fast with ServiceException(\"Request must contain identifier\") before any refresh logic runs.","triggerScenarios":"Invoking GenericRefreshProtocol.refresh() (directly or via a raw protobuf client) with a request built without setIdentifier(...); 'hdfs dfsadmin -refresh <host:port> <identifier>' without the identifier argument in a custom wrapper; version-skewed clients that do not populate the field.","commonSituations":"Writing custom admin tooling on top of GenericRefreshProtocol; test harnesses that hand-assemble protos; upgrading dfsadmin wrappers that previously passed positional args differently.","solutions":["Always populate the identifier before sending: builder.setIdentifier(\"namenode\") (the id a RefreshHandler registered under, e.g., 'namenode' for the NameNode's refresh handler).","Prefer the stock 'hdfs dfsadmin -refresh <host:port> <identifier> [args...]' CLI, which builds a well-formed request.","When implementing your own translator/service, catch ServiceException client-side and surface the message instead of swallowing it."],"exampleFix":"// before\nGenericRefreshRequestProto req = GenericRefreshRequestProto.newBuilder()\n    .addAllArgs(args).build();\n\n// after\nGenericRefreshRequestProto req = GenericRefreshRequestProto.newBuilder()\n    .setIdentifier(\"namenode\").addAllArgs(args).build();","handlingStrategy":"validation","validationCode":"// Client-side: check the field before sending\nif (!request.hasIdentifier()) {\n  throw new IllegalArgumentException(\"GenericRefreshRequest requires an identifier \"\n      + \"(the RefreshHandler id, e.g. 'namenode')\");\n}\nCollection<RefreshResponse> out = refreshProxy.refresh(request.getIdentifier(), args);","typeGuard":null,"tryCatchPattern":"try {\n  return pack(impl.refresh(request.getIdentifier(), args));\n} catch (ServiceException se) {\n  if (se.getMessage().contains(\"identifier\")) {\n    // malformed request from a custom/skewed client; reject with clear message\n    throw new ServiceException(\"Refresh request must set the 'identifier' field\", se);\n  }\n  throw se;\n}","preventionTips":["Always build GenericRefreshRequestProto with setIdentifier(<RefreshHandler id>).","Prefer the stock 'hdfs dfsadmin -refresh' client over hand-rolled protobuf calls.","In custom RefreshHandler implementations, log the identifier you register under so callers know what to send."],"tags":["hadoop","ipc","protobuf","refresh","dfsadmin","required-field"],"backgroundTag":"missing-required-field","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}