{"record":{"id":"49026848f4707a48","repo":"apache/hadoop","slug":"missing-marker-string-s","errorCode":null,"errorMessage":"Missing marker string: %s","messagePattern":"Missing marker string: (.+?)","errorType":"exception","errorClass":"NoRecordException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/JsonSerDeser.java","lineNumber":108,"sourceCode":"   * @throws IOException all problems\n   * @throws EOFException not enough data\n   * @throws InvalidRecordException if the JSON parsing failed.\n   * @throws NoRecordException if the data is not considered a record: either\n   * it is too short or it did not contain the marker string.\n   */\n  public T fromBytes(String path, byte[] bytes, String marker)\n      throws IOException {\n    int len = bytes.length;\n    if (len == 0 ) {\n      throw new NoRecordException(path, E_NO_DATA);\n    }\n    if (StringUtils.isNotEmpty(marker) && len < marker.length()) {\n      throw new NoRecordException(path, E_DATA_TOO_SHORT);\n    }\n    String json = new String(bytes, 0, len, StandardCharsets.UTF_8);\n    if (StringUtils.isNotEmpty(marker)\n        && !json.contains(marker)) {\n      throw new NoRecordException(path, E_MISSING_MARKER_STRING + marker);\n    }\n    try {\n      return fromJson(json);\n    } catch (JsonProcessingException e) {\n      throw new InvalidRecordException(path, e.toString(), e);\n    }\n  }\n\n}\n","sourceCodeStart":90,"sourceCodeEnd":118,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/JsonSerDeser.java#L90-L118","documentation":"fromBytes(path, bytes, marker) verifies the payload represents the expected record type by checking that the marker substring occurs in the UTF-8 decoded JSON. Registry code passes ServiceRecord.RECORD_TYPE ('JSONServiceRecord') as the marker; if the text does not contain it, NoRecordException ('Missing marker string: <marker>') is thrown instead of attempting a parse.","triggerScenarios":"A znode holding valid JSON that is not a ServiceRecord (different schema, user-written node), data written by a different serializer version, or hand-edited payloads read with the record marker.","commonSituations":"Reading user-written nodes (some registry entries are intentionally non-record data) with the record reader; schema drift between writer and reader versions; tests using arbitrary JSON fixtures where the 'type' field was renamed or removed.","solutions":["Match reader to format: check json.contains(marker) or the record's 'type' field before calling fromBytes with a marker","For nodes that are legitimately non-record data, call fromBytes without a marker (an empty marker skips all three NoRecord checks) or read raw bytes","If the node should be a record, rewrite it from a marshalled ServiceRecord (JsonSerDeser.toBytes stamps the type field)"],"exampleFix":"// before\nServiceRecord r = marshal.fromBytes(path, bytes, ServiceRecord.RECORD_TYPE);\n\n// after\nString json = new String(bytes, StandardCharsets.UTF_8);\nif (!json.contains(ServiceRecord.RECORD_TYPE)) {\n  return Optional.empty(); // foreign payload, not a service record\n}\nServiceRecord r = marshal.fromBytes(path, bytes, ServiceRecord.RECORD_TYPE);","handlingStrategy":"try-catch","validationCode":"String json = new String(bytes, StandardCharsets.UTF_8);\nif (StringUtils.isNotEmpty(marker) && !json.contains(marker)) {\n  return Optional.empty(); // foreign payload, not the expected record type\n}\nreturn Optional.of(marshal.fromBytes(path, bytes, marker));","typeGuard":null,"tryCatchPattern":"try {\n  return Optional.of(marshal.fromBytes(path, bytes, ServiceRecord.RECORD_TYPE));\n} catch (NoRecordException e) {\n  // 'Missing marker string' — node is valid data but not a ServiceRecord\n  LOG.debug(\"Non-record node at {}: {}\", path, e.toString());\n  return Optional.empty();\n} catch (IOException e) {\n  throw new IOException(\"Failed to read record at \" + path, e);\n}","preventionTips":["Read nodes with the reader matching their schema; user-written nodes must not go through the record marker path","Remember NoRecordException extends IOException — catch it before IOException in the same try block","Pass an empty marker when the payload is not expected to carry the record-type string"],"tags":["registry","zookeeper","serialization","schema"],"backgroundTag":"invalid-record-format","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}