{"record":{"id":"e8bcde2f0a9dd848","repo":"prestodb/presto","slug":"invalid-arguments-e8bcde","errorCode":"INVALID_ARGUMENTS","errorMessage":"Unable to serialize object of type ","messagePattern":"Unable to serialize object of type ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-thrift-connector-toolkit/src/main/java/com/facebook/presto/thrift/codec/GenericThriftCodec.java","lineNumber":55,"sourceCode":"        requireNonNull(javaType, \"javaType is null\");\n\n        if (!(javaType instanceof Class<?>)) {\n            throw new IllegalArgumentException(\"Expected a Class type for javaType, but got: \" + javaType.getTypeName());\n        }\n\n        Class<?> clazz = (Class<?>) javaType;\n\n        this.thriftCodec = (ThriftCodec<T>) codecManager.getCodec(clazz);\n    }\n\n    @Override\n    public byte[] serialize(T value)\n    {\n        try {\n            return toThrift(value, thriftCodec);\n        }\n        catch (TProtocolException e) {\n            throw new PrestoException(INVALID_ARGUMENTS, \"Unable to serialize object of type \" + value.getClass().getSimpleName(), e);\n        }\n    }\n\n    @Override\n    public T deserialize(byte[] bytes)\n    {\n        try {\n            return fromThrift(bytes, thriftCodec);\n        }\n        catch (TProtocolException e) {\n            throw new PrestoException(INVALID_ARGUMENTS, \"Unable to deserialize bytes to object of expected type\", e);\n        }\n    }\n}\n","sourceCodeStart":37,"sourceCodeEnd":70,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-thrift-connector-toolkit/src/main/java/com/facebook/presto/thrift/codec/GenericThriftCodec.java#L37-L70","documentation":"GenericThriftCodec.serialize delegates to the managed ThriftCodec; if serialization fails with TProtocolException it is rethrown as a PrestoException INVALID_ARGUMENTS naming the value's simple class. It indicates the object does not conform to what the Thrift codec expects.","triggerScenarios":"Calling serialize(value) (directly or via record/writeParquetColumnHive paths) where the value contains fields incompatible with the Thrift schema (null required fields, out-of-range values, wrong types).","commonSituations":"Sending events with missing required Thrift fields, strings/data exceeding protocol limits, or mismatched codec registration for the value's class.","solutions":["Validate the object's required Thrift fields are populated before serializing","Check that the codec registered for the class matches the actual value type","Inspect the wrapped TProtocolException cause for the offending field","Fix the value generation code producing invalid field values"],"exampleFix":"// before\nbyte[] bytes = codec.serialize(eventWithNullRequiredField);\n// after\nif (event.getRequiredField() == null) { throw new IllegalArgumentException(\"requiredField missing\"); }\nbyte[] bytes = codec.serialize(event);","handlingStrategy":"validation","validationCode":"requireNonNull(value); if (!value.getClass().equals(expectedThriftClass)) { throw new IllegalArgumentException(\"Expected \" + expectedThriftClass + \" got \" + value.getClass()); }","typeGuard":"boolean isSerializableThriftValue(Object v) { return v != null && codec.supportedType().isInstance(v); }","tryCatchPattern":"try { return codec.serialize(value); } catch (PrestoException e) { if (INVALID_ARGUMENTS == e.getErrorCode().getCode()) { log.error(\"Serialization failed for \" + value.getClass() + \", cause: \", e.getCause()); return null; } throw e; }","preventionTips":["Validate required Thrift fields before serializing","Keep codec registrations in sync with value classes","Log and inspect the TProtocolException cause for offending fields"],"tags":["thrift","serialization","invalid-arguments","thrift-connector-toolkit"],"backgroundTag":"serialization-failure","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"}