prestodb/presto · error · ParseError

PlanNode PlanNode

Error message

 PlanNode  PlanNode

What it means

from_json for std::shared_ptr<PlanNode> first extracts the subclass discriminator with p->getSubclassKey(j). If that step throws a json::parse_error (malformed JSON, or the document is not an object containing the expected '@type' key), the library wraps it and rethrows ParseError(std::string(e.what()) + " PlanNode PlanNode"). The doubled type name is just the generated message format; the real diagnostic is the nlohmann parse_error text prepended to it.

Source

Thrown at presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp:808

  }
  if (type == ".CallDistributedProcedureNode") {
    j = *std::static_pointer_cast<CallDistributedProcedureNode>(p);
    return;
  }
  if (type == "com.facebook.presto.sql.planner.plan.RPCNode") {
    j = *std::static_pointer_cast<RPCNode>(p);
    return;
  }

  throw TypeError(type + " no abstract type PlanNode ");
}

void from_json(const json& j, std::shared_ptr<PlanNode>& p) {
  String type;
  try {
    type = p->getSubclassKey(j);
  } catch (json::parse_error& e) {
    throw ParseError(std::string(e.what()) + " PlanNode  PlanNode");
  }

  if (type == ".AggregationNode") {
    std::shared_ptr<AggregationNode> k = std::make_shared<AggregationNode>();
    j.get_to(*k);
    p = std::static_pointer_cast<PlanNode>(k);
    return;
  }
  if (type == "com.facebook.presto.sql.planner.plan.GroupIdNode") {
    std::shared_ptr<GroupIdNode> k = std::make_shared<GroupIdNode>();
    j.get_to(*k);
    p = std::static_pointer_cast<PlanNode>(k);
    return;
  }
  if (type == ".DeleteNode") {
    std::shared_ptr<DeleteNode> k = std::make_shared<DeleteNode>();
    j.get_to(*k);
    p = std::static_pointer_cast<PlanNode>(k);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Read the prepended json::parse_error text (e.what()) to find the exact byte offset and cause of the malformed JSON.
  2. Log the raw response body received before deserialization to confirm a valid plan JSON object with an '@type' field was received.
  3. Check the coordinator endpoint/HTTP status handling: reject non-200 or non-JSON responses before calling from_json.
  4. Upgrade/align coordinator and native versions if the payload format changed (e.g. discriminator key renamed).

Example fix

// before: blindly parse whatever came back
// auto plan = resp.body; from_json(json::parse(plan), planNode); // ParseError on HTML error page
// after: guard the response first
// if (resp.status != 200 || resp.body.empty() || resp.body.front() != '{') throw std::runtime_error("bad plan payload");
// from_json(json::parse(resp.body), planNode);
Defensive patterns

Strategy: validation

Validate before calling

// Validate plan payload before from_json
bool isValidPlanNodePayload(const nlohmann::json& j) {
  return j.is_object() && j.contains("@type") && j["@type"].is_string();
}
// usage:
// nlohmann::json j = nlohmann::json::parse(body, nullptr, /*allow_exceptions=*/false);
// if (j.is_discarded() || !isValidPlanNodePayload(j)) throw std::invalid_argument("bad plan json");

Try / catch

try {
  from_json(j, planNode);
} catch (const facebook::presto::protocol::ParseError& e) {
  LOG(ERROR) << "PlanNode payload unparseable: " << e.what();
  // inspect raw body, re-request the fragment
}

Prevention

When it happens

Trigger: Calling from_json(json, std::shared_ptr<PlanNode>&) with input that fails JSON parsing or lacks a readable '@type' discriminator — e.g. a truncated plan fragment body, a non-object JSON value (array/string/number), or an HTTP exchange payload that returned an error page instead of plan JSON.

Common situations: Coordinator returned an HTTP error body (HTML/text) where the native worker expected plan JSON; truncated or corrupted exchange payloads; sending the wrong endpoint's response into the plan deserializer; encoding/charset issues corrupting the JSON.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/21861c995b869b7c. Report an issue: GitHub.