{"record":{"id":"fa7125a59671e822","repo":"prestodb/presto","slug":"functionhandle-functionhandle","errorCode":null,"errorMessage":" FunctionHandle  FunctionHandle","messagePattern":" FunctionHandle  FunctionHandle","errorType":"exception","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp","lineNumber":141,"sourceCode":"  }\n  if (type == \"sql_function_handle\") {\n    j = *std::static_pointer_cast<SqlFunctionHandle>(p);\n    return;\n  }\n  if (type == \"rest\") {\n    j = *std::static_pointer_cast<RestFunctionHandle>(p);\n    return;\n  }\n\n  throw TypeError(type + \" no abstract type FunctionHandle \");\n}\n\nvoid from_json(const json& j, std::shared_ptr<FunctionHandle>& p) {\n  String type;\n  try {\n    type = p->getSubclassKey(j);\n  } catch (json::parse_error& e) {\n    throw ParseError(std::string(e.what()) + \" FunctionHandle  FunctionHandle\");\n  }\n\n  if (type == \"$static\") {\n    std::shared_ptr<BuiltInFunctionHandle> k =\n        std::make_shared<BuiltInFunctionHandle>();\n    j.get_to(*k);\n    p = std::static_pointer_cast<FunctionHandle>(k);\n    return;\n  }\n  if (type == \"native\") {\n    std::shared_ptr<NativeFunctionHandle> k =\n        std::make_shared<NativeFunctionHandle>();\n    j.get_to(*k);\n    p = std::static_pointer_cast<FunctionHandle>(k);\n    return;\n  }\n  if (type == \"json_file\") {\n    std::shared_ptr<SqlFunctionHandle> k =","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp#L123-L159","documentation":"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.","triggerScenarios":"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.","commonSituations":"Protocol incompatibility between coordinator and native worker changing the FunctionHandle JSON layout; network-truncated task updates; malformed fixtures in tests.","solutions":["Inspect the raw JSON around the FunctionHandle field and validate it with a linter","Align coordinator and native worker protocol versions","Verify the producer emits the '_type' key inside a valid JSON object for every FunctionHandle","Catch ParseError at the deserialization entry point and log the payload for diagnosis"],"exampleFix":"// before: truncated payload\njson j = json::parse(chunk); // '{\"_type\":\"$stat' -> parse_error -> ParseError\nfrom_json(j, functionHandle);\n// after: validate first\njson j = json::parse(chunk);\nif (!j.is_object() || !j.contains(\"_type\")) {\n  throw std::runtime_error(\"Malformed FunctionHandle payload\");\n}\nfrom_json(j, functionHandle);","handlingStrategy":"try-catch","validationCode":"json j = json::parse(payload);\nif (!j.is_object() || !j.contains(\"_type\") || !j[\"_type\"].is_string()) {\n  throw std::runtime_error(\"FunctionHandle json must be an object with a string _type\");\n}","typeGuard":"bool isDeserializableFunctionHandle(const json& j) {\n  return j.is_object() && j.contains(\"_type\") && j[\"_type\"].is_string();\n}","tryCatchPattern":"try {\n  from_json(j, functionHandle);\n} catch (const facebook::presto::protocol::ParseError& e) {\n  LOG(ERROR) << \"FunctionHandle parse failed: \" << e.what() << \" payload=\" << j.dump();\n  throw;\n}","preventionTips":["Guard against truncated payloads before json::parse","Validate the '_type' field exists and is a string","Keep protocol versions aligned across coordinator and workers","Log raw payloads when ParseError occurs"],"tags":["json","deserialization","presto-protocol","function-handle"],"backgroundTag":"json-parse-error","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"}