{"record":{"id":"9485590c0f9dd726","repo":"prestodb/presto","slug":"rowexpression-rowexpression","errorCode":null,"errorMessage":" RowExpression  RowExpression","messagePattern":" RowExpression  RowExpression","errorType":"exception","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp","lineNumber":232,"sourceCode":"  }\n  if (type == \"lambda\") {\n    j = *std::static_pointer_cast<LambdaDefinitionExpression>(p);\n    return;\n  }\n  if (type == \"variable\") {\n    j = *std::static_pointer_cast<VariableReferenceExpression>(p);\n    return;\n  }\n\n  throw TypeError(type + \" no abstract type RowExpression \");\n}\n\nvoid from_json(const json& j, std::shared_ptr<RowExpression>& p) {\n  String type;\n  try {\n    type = p->getSubclassKey(j);\n  } catch (json::parse_error& e) {\n    throw ParseError(std::string(e.what()) + \" RowExpression  RowExpression\");\n  }\n\n  if (type == \"call\") {\n    std::shared_ptr<CallExpression> k = std::make_shared<CallExpression>();\n    j.get_to(*k);\n    p = std::static_pointer_cast<RowExpression>(k);\n    return;\n  }\n  if (type == \"constant\") {\n    std::shared_ptr<ConstantExpression> k =\n        std::make_shared<ConstantExpression>();\n    j.get_to(*k);\n    p = std::static_pointer_cast<RowExpression>(k);\n    return;\n  }\n  if (type == \"special\") {\n    std::shared_ptr<SpecialFormExpression> k =\n        std::make_shared<SpecialFormExpression>();","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp#L214-L250","documentation":"from_json for shared_ptr<RowExpression> reads the subclass discriminator with getSubclassKey; a nlohmann json::parse_error during that read is rethrown as a protocol ParseError with the suffix ' RowExpression  RowExpression'. This means the RowExpression JSON was structurally invalid before type dispatch could select a concrete expression class.","triggerScenarios":"Deserializing plan-node expressions where the JSON fragment for the RowExpression is malformed — non-object input, corruption/truncation, or an unexpected shape making getSubclassKey throw parse_error in facebook::presto::protocol::from_json.","commonSituations":"Truncated or corrupted plan payloads from the coordinator; protocol format drift between Java and native components; malformed test fixtures for expression trees.","solutions":["Dump and lint the raw JSON fragment for the failing expression","Check coordinator and native worker versions for RowExpression wire-format compatibility","Ensure producers emit the '_type' field within a valid JSON object for every expression","Wrap deserialization in try/catch(ParseError) and log the offending payload for triage"],"exampleFix":"// before: malformed expression json\njson j = json::parse(fragment); // '@call' garbage -> parse_error -> ParseError\nfrom_json(j, rowExpression);\n// after: guard before deserializing\njson j = json::parse(fragment);\nif (!j.is_object() || !j.contains(\"_type\")) {\n  throw std::runtime_error(\"Bad RowExpression json: \" + fragment);\n}\nfrom_json(j, rowExpression);","handlingStrategy":"try-catch","validationCode":"json j = json::parse(payload);\nif (!j.is_object() || !j.contains(\"_type\") || !j[\"_type\"].is_string()) {\n  throw std::runtime_error(\"RowExpression json must be an object with a string _type\");\n}","typeGuard":"bool isDeserializableRowExpression(const json& j) {\n  return j.is_object() && j.contains(\"_type\") && j[\"_type\"].is_string();\n}","tryCatchPattern":"try {\n  from_json(j, rowExpression);\n} catch (const facebook::presto::protocol::ParseError& e) {\n  LOG(ERROR) << \"RowExpression parse failed: \" << e.what() << \" payload=\" << j.dump();\n  throw;\n}","preventionTips":["Validate expression JSON structure before deserialization","Detect and retry on truncated plan payloads from the coordinator","Keep RowExpression wire format in sync between Java and native","Catch and log ParseError with the offending fragment"],"tags":["json","deserialization","presto-protocol","row-expression"],"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"}