{"record":{"id":"48a606ac84e40dce","repo":"prestodb/presto","slug":"parse-error-executionwritertarget-executionwrit","errorCode":null,"errorMessage":"{parse_error} ExecutionWriterTarget  ExecutionWriterTarget","messagePattern":"(.+?) ExecutionWriterTarget  ExecutionWriterTarget","errorType":"validation","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp","lineNumber":2430,"sourceCode":"  }\n  if (type == \"ExecuteProcedureHandle\") {\n    j = *std::static_pointer_cast<ExecuteProcedureHandle>(p);\n    return;\n  }\n  if (type == \"MergeHandle\") {\n    j = *std::static_pointer_cast<MergeHandle>(p);\n    return;\n  }\n\n  throw TypeError(type + \" no abstract type ExecutionWriterTarget \");\n}\n\nvoid from_json(const json& j, std::shared_ptr<ExecutionWriterTarget>& 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        \" ExecutionWriterTarget  ExecutionWriterTarget\");\n  }\n\n  if (type == \"CreateHandle\") {\n    std::shared_ptr<CreateHandle> k = std::make_shared<CreateHandle>();\n    j.get_to(*k);\n    p = std::static_pointer_cast<ExecutionWriterTarget>(k);\n    return;\n  }\n  if (type == \"RefreshMaterializedViewHandle\") {\n    std::shared_ptr<InsertHandle> k = std::make_shared<InsertHandle>();\n    j.get_to(*k);\n    p = std::static_pointer_cast<ExecutionWriterTarget>(k);\n    return;\n  }\n  if (type == \"InsertHandle\") {\n    std::shared_ptr<InsertHandle> k = std::make_shared<InsertHandle>();","sourceCodeStart":2412,"sourceCodeEnd":2448,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp#L2412-L2448","documentation":"from_json for std::shared_ptr<ExecutionWriterTarget> calls p->getSubclassKey(j) first; if that throws json::parse_error (invalid JSON or missing/unreadable '@type' discriminator), the library rethrows ParseError(e.what() + \" ExecutionWriterTarget  ExecutionWriterTarget\"). The failure happens before subtype dispatch, so the payload itself is unparseable rather than an unknown target type.","triggerScenarios":"Calling from_json(json, std::shared_ptr<ExecutionWriterTarget>&) with malformed JSON — truncated writer-target payloads, non-object JSON (array/string/null), or a body missing the '@type' key, typically from the TableWriteInfo/write section of a plan fragment.","commonSituations":"Corrupted exchange between coordinator and native worker; error pages fed into the deserializer; hand-built fixtures missing '@type'; coordinator/native protocol drift changing where or how the discriminator is stored.","solutions":["Read the prepended nlohmann parse_error text to pinpoint the syntax issue and offset.","Log the raw write-info JSON before deserialization and confirm it is a complete object with '@type'.","Validate HTTP responses (status/content-type) before passing bodies to from_json.","Version-align coordinator and native worker if serialization of writer targets changed."],"exampleFix":"// before: from_json(j, writerTarget); // ParseError on truncated body\n// after:\n// if (!j.is_object() || !j.contains(\"@type\")) throw std::invalid_argument(\"invalid ExecutionWriterTarget json\");\n// from_json(j, writerTarget);","handlingStrategy":"validation","validationCode":"// Validate write-target payload before deserialization\nbool isValidWriterTargetPayload(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() || !isValidWriterTargetPayload(j)) throw std::invalid_argument(\"bad writer target json\");","typeGuard":null,"tryCatchPattern":"try {\n  from_json(j, writerTarget);\n} catch (const facebook::presto::protocol::ParseError& e) {\n  LOG(ERROR) << \"ExecutionWriterTarget payload unparseable: \" << e.what();\n  // inspect raw TableWriteInfo json\n}","preventionTips":["Verify HTTP status and body completeness before deserializing write info.","Use non-throwing json::parse as a pre-filter for corrupted bodies.","Keep write-path payloads covered by round-trip serialization tests.","Log raw payloads on failure."],"tags":["json-parse-error","malformed-json","presto-native","writer-target"],"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"}