mscheong01 / krotoDC

Protobuf Kotlin Dataclass, Converter & Custom Kotlin Coroutine gRPC Generator
Apache License 2.0
91 stars 8 forks source link

Generated defaultValue for TIMESTAMP is `LocalDateTime.MIN` #6

Closed davin111 closed 1 year ago

davin111 commented 1 year ago

It causes an exception like below.

java.lang.IllegalArgumentException: Timestamp is not valid. See proto definition for valid values. Seconds (-31557014135596800) must be in range [-62,135,596,800, +253,402,300,799]. Nanos (0) must be in range [0, +999,999,999].
    at org.curioswitch.common.protobuf.json.ProtobufUtil.checkValid(ProtobufUtil.java:420)
    at org.curioswitch.common.protobuf.json.ProtobufUtil.formatTimestamp(ProtobufUtil.java:84)
    at org.curioswitch.common.protobuf.json.WellKnownTypeMarshaller$TimestampMarshaller.doWrite(WellKnownTypeMarshaller.java:279)
    at org.curioswitch.common.protobuf.json.WellKnownTypeMarshaller$TimestampMarshaller.doWrite(WellKnownTypeMarshaller.java:257)
    at org.curioswitch.common.protobuf.json.WellKnownTypeMarshaller$WrapperMarshaller.writeValue(WellKnownTypeMarshaller.java:64)
    at org.curioswitch.common.protobuf.json.SerializeSupport.printMessage(SerializeSupport.java:219)
    at org.curioswitch.common.protobuf.json.TypeSpecificMarshaller$ByteBuddy$diaKldbv.doWrite(Unknown Source)
    at org.curioswitch.common.protobuf.json.TypeSpecificMarshaller$ByteBuddy$diaKldbv.doWrite(Unknown Source)
    at org.curioswitch.common.protobuf.json.TypeSpecificMarshaller.writeValue(TypeSpecificMarshaller.java:88)

I think it should be something like com.google.protobuf.Timestamp.getDefaultInstance().toLocalDateTime().

Can I try to fix it?

mscheong01 commented 1 year ago

This is indeed a bug, and HandledPreDefinedTypes.kt will have to be fixed. Also, contributions are always welcome 😆.