Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events api: "Expected a string but was BEGIN_ARRAY at line 1 column 57 path $.data[0].error" exception #130

Open
arlekcangp opened this issue Jun 25, 2024 · 0 comments · May be fixed by #131

Comments

@arlekcangp
Copy link

arlekcangp commented Jun 25, 2024

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:

  1. Take an example of a bulk sending from the documentation
  2. Replace the name of event by any random and check that there is no workflow with this name in novu
  3. expected result: exception with message workflow_not_found Real result - gson exception.
@mayorJAY mayorJAY linked a pull request Jun 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant