AppsFlyer / pronto

Clojure support for protocol buffers
110 stars 8 forks source link

Failing access new Enum values when proto tag hasn't been updated. #19

Closed sagiron closed 1 year ago

sagiron commented 1 year ago

Pronto fails to access an enum value when an unknown enum value is introduced by messages of a newer proto tag. In such a case, the library will throw an exception.

For an Instance: --v1-- enum Problem { UNKNOWN_PROBLEM = 0; KNOWN_PROBLEM = 1; }

--v2-- enum Problem { UNKNOWN_PROBLEM = 0; KNOWN_PROBLEM = 1; PARTIALLY_KNOWN_PROBLEM = 2; }

Service A is updated to hold v2 of the proto and populate the Problem enum with field number 2, then it passes it to Service B which still holds v1 of the proto, which in term this service tries to extract the value of the problem and gets an exception.

chorin1 commented 1 year ago

To add more context, the error occurs when accessing an enum inside a proto-map and it contains an unknown enum value (the version was not yet updated).

can't wrap UNRECOGNIZED

java.lang.IllegalArgumentException: can't wrap UNRECOGNIZED
    at pronto.protos.engine.utils.common.mapper.x_events_base_v1_xEvent__DeviceProtoMap.valAt(common.clj:21)
    at clojure.lang.KeywordLookupSite$1.get(KeywordLookupSite.java:45)
    at engine.utils.conversions_handler$build_conversion.invokeStatic(conversions_handler.clj:55)

Caused by the following code:

; event is a proto-map and :platform is an enum
(-> event :device :platform)
nenorbot commented 1 year ago

@sagiron @chorin1 have you seen #20 ? I guess this should resolve it. I can't merge to this repo anymore unfortunately, but it's out there waiting for someone to close it...

(while you're at it, there's also #17 that's sadly been open for a very long time 😞 )

idantavor commented 1 year ago

fixed by #20