{"record":{"id":"b9d8cab5a214e328","repo":"apache/hadoop","slug":"address-type-of-s-does-not-match-required-type-of","errorCode":null,"errorMessage":"Address type of %s does not match required type of %s","messagePattern":"Address type of (.+?) does not match required type of (.+?)","errorType":"exception","errorClass":"InvalidRecordException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java","lineNumber":171,"sourceCode":"   * Create a (hostname, port) address pair\n   * @param address socket address whose hostname and port are used for the\n   * generated address.\n   * @return a 1 entry map.\n   */\n  public static Map<String, String> hostnamePortPair(InetSocketAddress address) {\n    return hostnamePortPair(address.getHostName(), address.getPort());\n  }\n\n  /**\n   * Require a specific address type on an endpoint\n   * @param required required type\n   * @param epr endpoint\n   * @throws InvalidRecordException if the type is wrong\n   */\n  public static void requireAddressType(String required, Endpoint epr) throws\n      InvalidRecordException {\n    if (!required.equals(epr.addressType)) {\n      throw new InvalidRecordException(\n          epr.toString(),\n          \"Address type of \" + epr.addressType\n          + \" does not match required type of \"\n          + required);\n    }\n  }\n\n  /**\n   * Get a single URI endpoint\n   * @param epr endpoint\n   * @return the uri of the first entry in the address list. Null if the endpoint\n   * itself is null\n   * @throws InvalidRecordException if the type is wrong, there are no addresses\n   * or the payload ill-formatted\n   */\n  public static List<String> retrieveAddressesUriType(Endpoint epr)\n      throws InvalidRecordException {\n    if (epr == null) {","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java#L153-L189","documentation":"RegistryTypeUtils.requireAddressType(expected, epr) enforces that an Endpoint's addressType matches what the accessor can parse — retrieveAddressesUriType requires AddressTypes.ADDRESS_URI ('uri'). A mismatch throws InvalidRecordException stating the actual and required types. Other known types include 'host/port' (ADDRESS_HOSTNAME_AND_PORT) with field 'host'.","triggerScenarios":"Calling retrieveAddressesUriType or retrieveAddressURLs on an endpoint published with host/port addressing (the style YARN API records use), or with any custom addressType string.","commonSituations":"Reading a mixed registry where some endpoints are URI-typed and others host/port-typed; consumer code assuming every endpoint of a service shares one address type.","solutions":["Branch on epr.addressType first: use retrieveAddressesUriType/retrieveAddressURLs for 'uri' endpoints and hostname/port accessors for 'host/port' endpoints","When publishing, stamp the type that matches the payload — RegistryTypeUtils.uri(...) already sets 'uri'","Catch InvalidRecordException per endpoint, log and skip the mismatched entry, and continue with the rest of the record"],"exampleFix":"// before\nList<URL> urls = RegistryTypeUtils.retrieveAddressURLs(endpoint); // endpoint is host/port typed\n\n// after\nif (AddressTypes.ADDRESS_URI.equals(endpoint.addressType)) {\n  List<URL> urls = RegistryTypeUtils.retrieveAddressURLs(endpoint);\n} else if (AddressTypes.ADDRESS_HOSTNAME_AND_PORT.equals(endpoint.addressType)) {\n  InetSocketAddress addr = RegistryTypeUtils.retrieveAddressAddr(endpoint);\n}","handlingStrategy":"validation","validationCode":"if (!AddressTypes.ADDRESS_URI.equals(endpoint.addressType)) {\n  // not a uri endpoint — use the hostname/port accessors instead of failing\n  InetSocketAddress sa = RegistryTypeUtils.retrieveAddressAddr(endpoint);\n} else {\n  List<String> uris = RegistryTypeUtils.retrieveAddressesUriType(endpoint);\n}","typeGuard":"static boolean isUriEndpoint(Endpoint epr) {\n  return epr != null && AddressTypes.ADDRESS_URI.equals(epr.addressType);\n}","tryCatchPattern":"for (Endpoint epr : record.external) {\n  try {\n    urls.addAll(RegistryTypeUtils.retrieveAddressURLs(epr));\n  } catch (InvalidRecordException e) {\n    LOG.warn(\"Skipping endpoint with wrong address type: {}\", e.getMessage());\n  }\n}","preventionTips":["Check epr.addressType before choosing an accessor — registries hold mixed 'uri' and 'host/port' endpoints","Publish with RegistryTypeUtils.uri(...)/hostnamePortPair(...) so the type always matches the payload","Process endpoints defensively: one malformed endpoint should not abort the whole record"],"tags":["registry","endpoint","address-type","validation"],"backgroundTag":"address-type-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}