{"record":{"id":"14e5a865cb63fa09","repo":"prestodb/presto","slug":"parse-error-connectormergetablehandle-connector","errorCode":null,"errorMessage":"{parse_error} ConnectorMergeTableHandle  ConnectorMergeTableHandle","messagePattern":"(.+?) ConnectorMergeTableHandle  ConnectorMergeTableHandle","errorType":"validation","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp","lineNumber":7578,"sourceCode":"// UPDATE/MERGE deserialization on the worker (MergeHandle.from_json ->\n// from_json_key(connectorMergeTableHandle) reaches here). Unlike the Delete/\n// Insert handles there is no deserialize(ConnectorMergeTableHandle) overload\n// on ConnectorProtocol, so the customSerializedValue branch is omitted.\nvoid to_json(json& j, const std::shared_ptr<ConnectorMergeTableHandle>& p) {\n  if (p == nullptr) {\n    return;\n  }\n  String type = p->_type;\n  getConnectorProtocol(type).to_json(j, p);\n}\n\nvoid from_json(const json& j, std::shared_ptr<ConnectorMergeTableHandle>& p) {\n  String type;\n  try {\n    JsonEncodedSubclass keyReader;\n    type = keyReader.getSubclassKey(j);\n  } catch (json::parse_error& e) {\n    throw ParseError(\n        std::string(e.what()) +\n        \" ConnectorMergeTableHandle  ConnectorMergeTableHandle\");\n  }\n\n  getConnectorProtocol(type).from_json(j, p);\n}\n} // namespace facebook::presto::protocol\nnamespace facebook::presto::protocol {\nMergeHandle::MergeHandle() noexcept {\n  _type = \"MergeHandle\";\n}\n\nvoid to_json(json& j, const MergeHandle& p) {\n  j = json::object();\n  j[\"@type\"] = \"MergeHandle\";\n  to_json_key(\n      j,\n      \"tableHandle\",","sourceCodeStart":7560,"sourceCodeEnd":7596,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp#L7560-L7596","documentation":"This ParseError is thrown while deserializing JSON into a shared_ptr<ConnectorMergeTableHandle>. Here a JsonEncodedSubclass key reader raises json::parse_error while extracting the subclass key, re-thrown as ParseError labeled 'ConnectorMergeTableHandle'. The merge handle JSON (used for MERGE/MERGE-DELETE plans) is syntactically invalid before connector-protocol dispatch.","triggerScenarios":"from_json invoked when deserializing a MERGE plan fragment whose ConnectorMergeTableHandle JSON is malformed; the JsonEncodedSubclass key extraction fails before getConnectorProtocol(type) dispatch.","commonSituations":"Running MERGE statements with a coordinator/native version mismatch (merge support newer on one side); connector with broken merge-handle serialization; corrupted plan JSON.","solutions":["Check that native execution supports the MERGE protocol version in use; align coordinator and native worker versions","Validate the merge handle JSON fragment with a standalone parser to find the syntax error","Fix the connector-side ConnectorMergeTableHandle JSON encoding","Log the full plan JSON for the MERGE statement and reproduce the parse in isolation"],"exampleFix":"// before\nproto::from_json(mergeHandleJson, mergeHandle);\n// after\njson j = json::parse(mergeHandleJson);\nif (!j.contains(\"type\")) throw std::runtime_error(\"missing merge handle type\");\nproto::from_json(j, mergeHandle);","handlingStrategy":"validation","validationCode":"json j = json::parse(mergeHandleJson);\nif (!j.is_object() || !j.contains(\"type\")) {\n  throw std::runtime_error(\"ConnectorMergeTableHandle JSON invalid: missing 'type'\");\n}\n// also confirm native side supports the merge protocol\nif (!supportsMergeProtocol()) throw std::runtime_error(\"native merge protocol not supported\");","typeGuard":"bool isWellFormedMergeHandleJson(const json& j) {\n  return j.is_object() && j.contains(\"type\") && j[\"type\"].is_string();\n}","tryCatchPattern":"try {\n  proto::from_json(j, mergeHandle);\n} catch (const ParseError& e) {\n  LOG(ERROR) << \"bad ConnectorMergeTableHandle JSON: \" << e.what();\n  throw;\n}","preventionTips":["Confirm native worker supports the MERGE protocol version in use","Validate merge handle JSON before deserialization","Align coordinator/native versions when enabling MERGE","Check connector merge-handle serialization"],"tags":["json","deserialization","parse-error","merge"],"backgroundTag":"json-parse-error","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}