{"record":{"id":"19e92c6bed4a7c5c","repo":"prestodb/presto","slug":"parse-error-connectortransactionhandle-connecto","errorCode":null,"errorMessage":"{parse_error} ConnectorTransactionHandle  ConnectorTransactionHandle","messagePattern":"(.+?) ConnectorTransactionHandle  ConnectorTransactionHandle","errorType":"validation","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp","lineNumber":1224,"sourceCode":"void to_json(json& j, const std::shared_ptr<ConnectorTransactionHandle>& p) {\n  if (p == nullptr) {\n    return;\n  }\n  String type = p->_type;\n\n  if (type == \"$remote\") {\n    j = *std::static_pointer_cast<RemoteTransactionHandle>(p);\n    return;\n  }\n  getConnectorProtocol(type).to_json(j, p);\n}\n\nvoid from_json(const json& j, std::shared_ptr<ConnectorTransactionHandle>& p) {\n  String type;\n  try {\n    type = p->getSubclassKey(j);\n  } catch (json::parse_error& e) {\n    throw ParseError(\n        std::string(e.what()) +\n        \" ConnectorTransactionHandle  ConnectorTransactionHandle\");\n  }\n\n  if (j.contains(\"customSerializedValue\")) {\n    VELOX_CHECK(\n        !type.empty() && type[0] != '$',\n        \"Internal handle type '{}' should not have customSerializedValue\",\n        type);\n    std::string binaryData = velox::encoding::Base64::decode(\n        j[\"customSerializedValue\"].get<std::string>());\n    getConnectorProtocol(type).deserialize(binaryData, p);\n    return;\n  }\n\n  if (type == \"$remote\") {\n    auto k = std::make_shared<RemoteTransactionHandle>();\n    j.get_to(*k);","sourceCodeStart":1206,"sourceCodeEnd":1242,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp#L1206-L1242","documentation":"from_json for std::shared_ptr<ConnectorTransactionHandle> reads the subclass discriminator with getSubclassKey(j); a json::parse_error there is rethrown as ParseError(e.what() + \" ConnectorTransactionHandle  ConnectorTransactionHandle\"). The error is raised while identifying which concrete transaction handle to construct, so the payload failed JSON parsing or lacks the '@type' discriminator before dispatch.","triggerScenarios":"Calling from_json(json, std::shared_ptr<ConnectorTransactionHandle>&) with an invalid JSON document (syntax error, non-object value, missing '@type') — for example a session/transaction payload that was truncated or is actually an error response.","commonSituations":"Bad responses from the coordinator stored/forwarded as transaction handles; manually constructed test JSON missing '@type'; network truncation of the transaction section of a larger request; schema drift after upgrading the coordinator.","solutions":["Read the embedded json::parse_error message (e.what()) for the precise syntax problem and offset.","Validate the JSON is an object containing '@type' before calling from_json.","Re-acquire or re-request the transaction payload if it was corrupted or truncated in transit.","Ensure coordinator and native worker are version-aligned so the discriminator contract matches."],"exampleFix":"// before: trusting any JSON blob as a transaction handle\n// from_json(j, txnHandle);\n// after: pre-validate\n// if (!j.is_object() || !j.contains(\"@type\")) throw std::invalid_argument(\"missing @type for ConnectorTransactionHandle\");\n// from_json(j, txnHandle);","handlingStrategy":"validation","validationCode":"// Validate transaction handle payload before from_json\nbool isValidTransactionHandlePayload(const nlohmann::json& j) {\n  return j.is_object() && j.contains(\"@type\") && j[\"@type\"].is_string();\n}\n// usage before calling from_json(j, txnHandle);","typeGuard":null,"tryCatchPattern":"try {\n  from_json(j, txnHandle);\n} catch (const facebook::presto::protocol::ParseError& e) {\n  LOG(ERROR) << \"ConnectorTransactionHandle unparseable: \" << e.what();\n  // re-acquire the transaction payload\n}","preventionTips":["Pre-validate '@type' presence in transaction payloads.","Do not cache/forward payloads from failed coordinator responses.","Log raw JSON on parse failure for offset-level triage.","Keep serialization contract tests across coordinator/native versions."],"tags":["json-parse-error","malformed-json","presto-native","transaction-handle"],"backgroundTag":"malformed-json-payload","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"}