{"record":{"id":"e1f731fc7374c062","repo":"prestodb/presto","slug":"parse-error-connectorsplit","errorCode":null,"errorMessage":"{parse_error} ConnectorSplit","messagePattern":"(.+?) ConnectorSplit","errorType":"validation","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp","lineNumber":2568,"sourceCode":"  String type = p->_type;\n\n  if (type == \"$remote\") {\n    j = *std::static_pointer_cast<RemoteSplit>(p);\n    return;\n  }\n  if (type == \"$empty\") {\n    j = *std::static_pointer_cast<EmptySplit>(p);\n    return;\n  }\n  getConnectorProtocol(type).to_json(j, p);\n}\n\nvoid from_json(const json& j, std::shared_ptr<ConnectorSplit>& p) {\n  String type;\n  try {\n    type = p->getSubclassKey(j);\n  } catch (json::parse_error& e) {\n    throw ParseError(std::string(e.what()) + \" ConnectorSplit\");\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<RemoteSplit>();\n    j.get_to(*k);\n    p = k;\n    return;","sourceCodeStart":2550,"sourceCodeEnd":2586,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp#L2550-L2586","documentation":"from_json for std::shared_ptr<ConnectorSplit> starts by extracting the subclass discriminator via p->getSubclassKey(j); if nlohmann raises json::parse_error there (malformed JSON, non-object document, or missing '@type'), it rethrows ParseError(std::string(e.what()) + \" ConnectorSplit\"). Note the message only appends one type name (unlike some sibling messages), so the meaningful part is the nlohmann parse_error text at the front.","triggerScenarios":"Calling from_json(json, std::shared_ptr<ConnectorSplit>&) with input that fails JSON parsing before dispatch — e.g. a truncated split list from a stage's task description, a non-object JSON value, or a missing '@type' discriminator in the split payload.","commonSituations":"Large split payloads truncated in transit; coordinator error responses (HTML/JSON error) passed to the split deserializer; hand-built split fixtures missing '@type'; protocol/key-name drift between coordinator versions.","solutions":["Read the leading json::parse_error text for the exact cause and byte offset.","Log the raw split JSON before deserialization and verify it is a complete object with '@type'.","Check transport integrity (HTTP status, content-length) and re-fetch corrupted payloads.","Validate/pre-parse the JSON (is_object + contains(\"@type\")) before calling from_json."],"exampleFix":"// before: from_json(splitJson, connectorSplit); // ParseError: syntax error at byte N\n// after:\n// if (!splitJson.is_object() || !splitJson.contains(\"@type\")) throw std::invalid_argument(\"invalid ConnectorSplit json\");\n// from_json(splitJson, connectorSplit);","handlingStrategy":"validation","validationCode":"// Validate split payload before deserialization\nbool isValidConnectorSplitPayload(const nlohmann::json& j) {\n  return j.is_object() && j.contains(\"@type\") && j[\"@type\"].is_string();\n}\n// nlohmann::json j = nlohmann::json::parse(body, nullptr, false);\n// if (j.is_discarded() || !isValidConnectorSplitPayload(j)) throw std::invalid_argument(\"bad connector split json\");","typeGuard":null,"tryCatchPattern":"try {\n  from_json(j, connectorSplit);\n} catch (const facebook::presto::protocol::ParseError& e) {\n  LOG(ERROR) << \"ConnectorSplit unparseable: \" << e.what();\n  // re-fetch the split payload and check transport integrity\n}","preventionTips":["Check content-length/status to catch truncated split payloads.","Pre-parse with allow_exceptions=false before from_json.","Never deserialize non-200 or error-body responses.","Version-align coordinator and native workers for split schemas."],"tags":["json-parse-error","malformed-json","presto-native","connector-split"],"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"}