prestodb/presto · error · ParseError

{parse_error} ConnectorIndexHandle ConnectorIndexHandle

Error message

{parse_error} ConnectorIndexHandle ConnectorIndexHandle

What it means

This ParseError is thrown while deserializing a JSON payload into a shared_ptr<ConnectorIndexHandle>. The nlohmann json parser failed while reading the subclass key via getSubclassKey(j), so the protocol layer wraps the raw json::parse_error and appends 'ConnectorIndexHandle' for context. It means the incoming JSON fragment is syntactically malformed, not semantically wrong.

Source

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

      "VariableReferenceExpression",
      "groupIdVariable");
}
} // namespace facebook::presto::protocol
namespace facebook::presto::protocol {
void to_json(json& j, const std::shared_ptr<ConnectorIndexHandle>& p) {
  if (p == nullptr) {
    return;
  }
  String type = p->_type;
  getConnectorProtocol(type).to_json(j, p);
}

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

  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
namespace facebook::presto::protocol {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Capture the full raw plan JSON and validate it with a strict JSON parser to find the malformed span
  2. Verify coordinator and native worker use the same Presto/sp protocol version
  3. Check the connector's serialized ConnectorIndexHandle output for invalid escapes or partial writes
  4. Re-run with the plan fragment logged (json.dump()) to isolate the exact field

Example fix

// before: passing a hand-trimmed fragment
proto::from_json(trimmedJson, indexHandle);
// after: validate the JSON parses before handing it to the protocol layer
auto j = json::parse(planJson); // throws with byte offset if malformed
proto::from_json(j, indexHandle);
Defensive patterns

Strategy: validation

Validate before calling

json j;
try { j = json::parse(planFragmentJson); }
catch (const json::parse_error& e) {
  throw std::runtime_error(std::string("malformed plan JSON: ") + e.what());
}
if (!j.is_object()) throw std::runtime_error("plan fragment must be a JSON object");

Type guard

bool isValidJson(const std::string& s, json* out = nullptr) {
  try { if (out) *out = json::parse(s); return true; }
  catch (const json::parse_error&) { return false; }
}

Try / catch

try {
  proto::from_json(j, indexHandle);
} catch (const ParseError& e) {
  LOG(ERROR) << "bad ConnectorIndexHandle JSON: " << e.what() << " payload=" << j.dump();
  throw;
}

Prevention

When it happens

Trigger: Calling from_json on a JSON object whose 'type'/key region for a ConnectorIndexHandle is truncated, contains invalid escape sequences, wrong encoding, or is not a well-formed JSON value; typically during deserialization of a TableScanNode/IndexSourceNode plan fragment from the coordinator.

Common situations: Coordinator and native worker protocol version mismatch producing a corrupted or hand-edited plan JSON; a custom connector emitting non-JSON bytes in customSerializedValue; HTTP truncation of the plan body.

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/e3b0ef81a675f8c5. Report an issue: GitHub.