{"record":{"id":"c65c5ac4a1ad0452","repo":"prestodb/presto","slug":"invalid-arguments-c65c5a","errorCode":"INVALID_ARGUMENTS","errorMessage":"Can not serialize remote transaction handle","messagePattern":"Can not serialize remote transaction handle","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/thrift/RemoteTransactionHandleCodec.java","lineNumber":46,"sourceCode":"\npublic class RemoteTransactionHandleCodec\n        implements ConnectorCodec<ConnectorTransactionHandle>\n{\n    private final Provider<ThriftCodecManager> thriftCodecManagerProvider;\n\n    public RemoteTransactionHandleCodec(Provider<ThriftCodecManager> thriftCodecManagerProvider)\n    {\n        this.thriftCodecManagerProvider = requireNonNull(thriftCodecManagerProvider, \"thriftCodecManagerProvider is null\");\n    }\n\n    @Override\n    public byte[] serialize(ConnectorTransactionHandle handle)\n    {\n        try {\n            return toThrift((RemoteTransactionHandle) handle, thriftCodecManagerProvider.get().getCodec(RemoteTransactionHandle.class));\n        }\n        catch (TProtocolException e) {\n            throw new PrestoException(INVALID_ARGUMENTS, \"Can not serialize remote transaction handle\", e);\n        }\n    }\n\n    @Override\n    public ConnectorTransactionHandle deserialize(byte[] bytes)\n    {\n        try {\n            return fromThrift(bytes, thriftCodecManagerProvider.get().getCodec(RemoteTransactionHandle.class));\n        }\n        catch (TProtocolException e) {\n            throw new PrestoException(INVALID_ARGUMENTS, \"Can not deserialize remote transaction handle\", e);\n        }\n    }\n}\n","sourceCodeStart":28,"sourceCodeEnd":61,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/thrift/RemoteTransactionHandleCodec.java#L28-L61","documentation":"RemoteTransactionHandleCodec.serialize encodes a ConnectorTransactionHandle (cast to RemoteTransactionHandle) into Thrift bytes so transaction context can accompany remote splits. A TProtocolException during encoding is converted to PrestoException INVALID_ARGUMENTS because an unencodable transaction handle is invalid input.","triggerScenarios":"Calling serialize() with a handle whose Thrift-registered fields raise TProtocolException during toThrift, or a handle type that fails the RemoteTransactionHandle cast path.","commonSituations":"Custom connector transaction handles incompatible with the registered Thrift codec; corrupted handle state after coordinator failover; Thrift codec version mismatches.","solutions":["Inspect the cause TProtocolException to find the offending field","Ensure the handle is a RemoteTransactionHandle built through the intended remote-exchange path","Confirm the Thrift codec manager resolves the expected RemoteTransactionHandle codec","Regenerate the transaction handle from the connector instead of reusing a corrupted one"],"exampleFix":"// before\nreturn toThrift((RemoteTransactionHandle) handle, thriftCodecManagerProvider.get().getCodec(RemoteTransactionHandle.class));\n// after\nif (!(handle instanceof RemoteTransactionHandle)) {\n    throw new PrestoException(INVALID_ARGUMENTS, \"Expected RemoteTransactionHandle, got \" + handle.getClass().getSimpleName());\n}\nreturn toThrift((RemoteTransactionHandle) handle, thriftCodecManagerProvider.get().getCodec(RemoteTransactionHandle.class));","handlingStrategy":"validation","validationCode":"if (!(handle instanceof RemoteTransactionHandle)) {\n    throw new PrestoException(INVALID_ARGUMENTS, \"serialize expects RemoteTransactionHandle, got \" + handle.getClass().getName());\n}","typeGuard":"boolean isEncodableTransactionHandle(ConnectorTransactionHandle handle) {\n    return handle instanceof RemoteTransactionHandle;\n}","tryCatchPattern":"try {\n    byte[] bytes = codec.serialize(handle);\n} catch (PrestoException e) {\n    if (INVALID_ARGUMENTS.equals(e.getErrorCode())) {\n        LOG.error(e, \"Unserializable transaction handle; regenerating from connector\");\n        throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Transaction handle encode failed\", e);\n    }\n    throw e;\n}","preventionTips":["Obtain transaction handles from the connector's beginTransaction flow, not custom construction","Inspect the TProtocolException cause to identify offending fields","Keep the transaction-handle Thrift schema in sync cluster-wide","Avoid persisting serialized handles across Presto upgrades"],"tags":["serialization","thrift","transaction-handle"],"backgroundTag":"thrift-serialization-failed","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"}