prestodb/presto · error · ParseError

FunctionHandle FunctionHandle

Error message

 FunctionHandle  FunctionHandle

What it means

from_json for shared_ptr<FunctionHandle> obtains the subclass discriminator via getSubclassKey; if nlohmann raises json::parse_error during that access, the code rethrows it as a facebook::presto::protocol ParseError with the suffix ' FunctionHandle FunctionHandle'. It indicates the FunctionHandle JSON itself is structurally invalid, prior to any subclass dispatch.

Source

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

  }
  if (type == "sql_function_handle") {
    j = *std::static_pointer_cast<SqlFunctionHandle>(p);
    return;
  }
  if (type == "rest") {
    j = *std::static_pointer_cast<RestFunctionHandle>(p);
    return;
  }

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

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

  if (type == "$static") {
    std::shared_ptr<BuiltInFunctionHandle> k =
        std::make_shared<BuiltInFunctionHandle>();
    j.get_to(*k);
    p = std::static_pointer_cast<FunctionHandle>(k);
    return;
  }
  if (type == "native") {
    std::shared_ptr<NativeFunctionHandle> k =
        std::make_shared<NativeFunctionHandle>();
    j.get_to(*k);
    p = std::static_pointer_cast<FunctionHandle>(k);
    return;
  }
  if (type == "json_file") {
    std::shared_ptr<SqlFunctionHandle> k =

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the raw JSON around the FunctionHandle field and validate it with a linter
  2. Align coordinator and native worker protocol versions
  3. Verify the producer emits the '_type' key inside a valid JSON object for every FunctionHandle
  4. Catch ParseError at the deserialization entry point and log the payload for diagnosis

Example fix

// before: truncated payload
json j = json::parse(chunk); // '{"_type":"$stat' -> parse_error -> ParseError
from_json(j, functionHandle);
// after: validate first
json j = json::parse(chunk);
if (!j.is_object() || !j.contains("_type")) {
  throw std::runtime_error("Malformed FunctionHandle payload");
}
from_json(j, functionHandle);
Defensive patterns

Strategy: try-catch

Validate before calling

json j = json::parse(payload);
if (!j.is_object() || !j.contains("_type") || !j["_type"].is_string()) {
  throw std::runtime_error("FunctionHandle json must be an object with a string _type");
}

Type guard

bool isDeserializableFunctionHandle(const json& j) {
  return j.is_object() && j.contains("_type") && j["_type"].is_string();
}

Try / catch

try {
  from_json(j, functionHandle);
} catch (const facebook::presto::protocol::ParseError& e) {
  LOG(ERROR) << "FunctionHandle parse failed: " << e.what() << " payload=" << j.dump();
  throw;
}

Prevention

When it happens

Trigger: Deserializing a plan node or function-registry payload where the FunctionHandle JSON is corrupted, not an object, or shaped so that getSubclassKey's json operations throw parse_error inside facebook::presto::protocol::from_json.

Common situations: Protocol incompatibility between coordinator and native worker changing the FunctionHandle JSON layout; network-truncated task updates; malformed fixtures in tests.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


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