Events api: "Expected a string but was BEGIN_ARRAY at line 1 column 57 path $.data[0].error" exception #130
Open
Description
When trying to send an event, an error occurs. I conducted a debugging session and it seems that this API has changed the response format in case of an error. Now, instead of one string, an array is returned. The description in the "API" section (https://docs.novu.co/api-reference/events/trigger-event) contains error string[]
, but the object TriggerEventResponseData
contains only a simple private String error
.
And if an error is returned, the gson parser throws an exception Expected a string but was BEGIN_ARRAY at line 1 column 57 path $.data[0].error
that hides the real error.
Stacktrace:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 57 path $.data[0].error
frontapi-1 | at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224)
frontapi-1 | at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
frontapi-1 | at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
frontapi-1 | at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
frontapi-1 | at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
frontapi-1 | at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
frontapi-1 | at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:40)
frontapi-1 | at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)
frontapi-1 | at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
frontapi-1 | at retrofit2.OkHttpCall.execute(OkHttpCall.java:204)
frontapi-1 | at co.novu.api.events.EventsHandler.bulkTriggerEvent(EventsHandler.java:34)
frontapi-1 | at co.novu.common.base.Novu.bulkTriggerEvent(Novu.java:211)
How to reproduce:
- Take an example of a bulk sending from the documentation
- Replace the name of event by any random and check that there is no workflow with this name in novu
- expected result: exception with message
workflow_not_found
Real result - gson exception.
Metadata
Assignees
Labels
No labels