{"record":{"id":"50ccd03237634ca4","repo":"prestodb/presto","slug":"connectortablehandle-connectortablehandle","errorCode":null,"errorMessage":" ConnectorTableHandle  ConnectorTableHandle","messagePattern":" ConnectorTableHandle  ConnectorTableHandle","errorType":"exception","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp","lineNumber":1183,"sourceCode":"  from_json_key(j, \"type\", p.type, \"AllOrNoneValueSet\", \"Type\", \"type\");\n  from_json_key(j, \"all\", p.all, \"AllOrNoneValueSet\", \"bool\", \"all\");\n}\n} // namespace facebook::presto::protocol\nnamespace facebook::presto::protocol {\nvoid to_json(json& j, const std::shared_ptr<ConnectorTableHandle>& p) {\n  if (p == nullptr) {\n    return;\n  }\n  String type = p->_type;\n  getConnectorProtocol(type).to_json(j, p);\n}\n\nvoid from_json(const json& j, std::shared_ptr<ConnectorTableHandle>& p) {\n  String type;\n  try {\n    type = p->getSubclassKey(j);\n  } catch (json::parse_error& e) {\n    throw ParseError(\n        std::string(e.what()) + \" ConnectorTableHandle  ConnectorTableHandle\");\n  }\n\n  if (j.contains(\"customSerializedValue\")) {\n    VELOX_CHECK(\n        !type.empty() && type[0] != '$',\n        \"Internal handle type '{}' should not have customSerializedValue\",\n        type);\n    std::string binaryData = velox::encoding::Base64::decode(\n        j[\"customSerializedValue\"].get<std::string>());\n    getConnectorProtocol(type).deserialize(binaryData, p);\n    return;\n  }\n\n  getConnectorProtocol(type).from_json(j, p);\n}\n} // namespace facebook::presto::protocol\n// dependency TpchTransactionHandle","sourceCodeStart":1165,"sourceCodeEnd":1201,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp#L1165-L1201","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the prepended nlohmann parse_error text for the exact cause and byte offset.","Log the raw JSON body before from_json to verify it is a complete JSON object with '@type'.","Validate HTTP status/content-type and reject error bodies before deserializing handles.","Align coordinator/native versions if the handle serialization format changed."],"exampleFix":"// before: j.get_to / from_json directly on response body\n// from_json(j, tableHandle); // ParseError: syntax error while parsing...\n// after: validate first\n// if (!j.is_object() || !j.contains(\"@type\")) throw std::invalid_argument(\"not a ConnectorTableHandle payload\");\n// from_json(j, tableHandle);","handlingStrategy":"validation","validationCode":"// Validate table handle payload before deserialization\nbool isValidConnectorTableHandlePayload(const nlohmann::json& j) {\n  return j.is_object() && j.contains(\"@type\") && j[\"@type\"].is_string();\n}\n// nlohmann::json j = nlohmann::json::parse(body, nullptr, false);\n// if (j.is_discarded() || !isValidConnectorTableHandlePayload(j)) throw std::invalid_argument(\"bad table handle json\");","typeGuard":null,"tryCatchPattern":"try {\n  from_json(j, tableHandle);\n} catch (const facebook::presto::protocol::ParseError& e) {\n  LOG(ERROR) << \"ConnectorTableHandle payload unparseable: \" << e.what();\n  // re-request or rebuild the handle payload\n}","preventionTips":["Reject non-object/error-response bodies before handle deserialization.","Guard large handle payloads against transport truncation (check content-length).","Use json::parse with allow_exceptions=false as a pre-filter.","Version-align coordinator and native workers."],"tags":["json-parse-error","malformed-json","presto-native","connector-table-handle"],"backgroundTag":"malformed-json-payload","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}