prestodb/presto · error · ParseError

ConnectorTableHandle ConnectorTableHandle

Error message

 ConnectorTableHandle  ConnectorTableHandle

What it means

from_json for std::shared_ptr<ConnectorTableHandle> extracts the subclass discriminator via getSubclassKey(j); a json::parse_error during that step is wrapped and rethrown as ParseError(std::string(e.what()) + " ConnectorTableHandle ConnectorTableHandle"). It is thrown before any subtype dispatch, meaning the JSON itself could not be parsed/read rather than the handle type being unknown.

Source

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

  from_json_key(j, "type", p.type, "AllOrNoneValueSet", "Type", "type");
  from_json_key(j, "all", p.all, "AllOrNoneValueSet", "bool", "all");
}
} // namespace facebook::presto::protocol
namespace facebook::presto::protocol {
void to_json(json& j, const std::shared_ptr<ConnectorTableHandle>& p) {
  if (p == nullptr) {
    return;
  }
  String type = p->_type;
  getConnectorProtocol(type).to_json(j, p);
}

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

  if (j.contains("customSerializedValue")) {
    VELOX_CHECK(
        !type.empty() && type[0] != '$',
        "Internal handle type '{}' should not have customSerializedValue",
        type);
    std::string binaryData = velox::encoding::Base64::decode(
        j["customSerializedValue"].get<std::string>());
    getConnectorProtocol(type).deserialize(binaryData, p);
    return;
  }

  getConnectorProtocol(type).from_json(j, p);
}
} // namespace facebook::presto::protocol
// dependency TpchTransactionHandle

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the prepended nlohmann parse_error text for the exact cause and byte offset.
  2. Log the raw JSON body before from_json to verify it is a complete JSON object with '@type'.
  3. Validate HTTP status/content-type and reject error bodies before deserializing handles.
  4. Align coordinator/native versions if the handle serialization format changed.

Example fix

// before: j.get_to / from_json directly on response body
// from_json(j, tableHandle); // ParseError: syntax error while parsing...
// after: validate first
// if (!j.is_object() || !j.contains("@type")) throw std::invalid_argument("not a ConnectorTableHandle payload");
// from_json(j, tableHandle);
Defensive patterns

Strategy: validation

Validate before calling

// Validate table handle payload before deserialization
bool isValidConnectorTableHandlePayload(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() || !isValidConnectorTableHandlePayload(j)) throw std::invalid_argument("bad table handle json");

Try / catch

try {
  from_json(j, tableHandle);
} catch (const facebook::presto::protocol::ParseError& e) {
  LOG(ERROR) << "ConnectorTableHandle payload unparseable: " << e.what();
  // re-request or rebuild the handle payload
}

Prevention

When it happens

Trigger: Calling from_json(json, std::shared_ptr<ConnectorTableHandle>&) with malformed JSON, a non-object document, or one missing the '@type' discriminator — e.g. a table handle payload corrupted in transit or an error response fed to the handle deserializer.

Common situations: Corrupted exchange messages between coordinator and native worker; deserializing an error/HTML body as a table handle; truncation of large handle payloads over HTTP; protocol change altering the discriminator key.

Related errors


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