prestodb/presto · error · ParseError

{parse_error} ExecutionWriterTarget ExecutionWriterTarget

Error message

{parse_error} ExecutionWriterTarget  ExecutionWriterTarget

What it means

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.

Source

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

  }
  if (type == "ExecuteProcedureHandle") {
    j = *std::static_pointer_cast<ExecuteProcedureHandle>(p);
    return;
  }
  if (type == "MergeHandle") {
    j = *std::static_pointer_cast<MergeHandle>(p);
    return;
  }

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

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

  if (type == "CreateHandle") {
    std::shared_ptr<CreateHandle> k = std::make_shared<CreateHandle>();
    j.get_to(*k);
    p = std::static_pointer_cast<ExecutionWriterTarget>(k);
    return;
  }
  if (type == "RefreshMaterializedViewHandle") {
    std::shared_ptr<InsertHandle> k = std::make_shared<InsertHandle>();
    j.get_to(*k);
    p = std::static_pointer_cast<ExecutionWriterTarget>(k);
    return;
  }
  if (type == "InsertHandle") {
    std::shared_ptr<InsertHandle> k = std::make_shared<InsertHandle>();

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Read the prepended nlohmann parse_error text to pinpoint the syntax issue and offset.
  2. Log the raw write-info JSON before deserialization and confirm it is a complete object with '@type'.
  3. Validate HTTP responses (status/content-type) before passing bodies to from_json.
  4. Version-align coordinator and native worker if serialization of writer targets changed.

Example fix

// before: from_json(j, writerTarget); // ParseError on truncated body
// after:
// if (!j.is_object() || !j.contains("@type")) throw std::invalid_argument("invalid ExecutionWriterTarget json");
// from_json(j, writerTarget);
Defensive patterns

Strategy: validation

Validate before calling

// Validate write-target payload before deserialization
bool isValidWriterTargetPayload(const nlohmann::json& j) {
  return j.is_object() && j.contains("@type") && j["@type"].is_string();
}
// nlohmann::json j = nlohmann::json::parse(body, nullptr, false);
// if (j.is_discarded() || !isValidWriterTargetPayload(j)) throw std::invalid_argument("bad writer target json");

Try / catch

try {
  from_json(j, writerTarget);
} catch (const facebook::presto::protocol::ParseError& e) {
  LOG(ERROR) << "ExecutionWriterTarget payload unparseable: " << e.what();
  // inspect raw TableWriteInfo json
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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