java-slack-sdk icon indicating copy to clipboard operation
java-slack-sdk copied to clipboard

Deserialization issue with slack sdk with message attachments

Open rasharab opened this issue 8 months ago • 7 comments

Noticed this with one of our customers:

j.l.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 265032 path $.messages[115].attachments[0].list_records[0].fields[1].message See https://github.com/google/gson/blob/main/Troubleshooting.md#unexpected-json-structure at c.g.g.s.JsonReader.unexpectedTokenError(JsonReader.java:1768) at c.g.g.s.JsonReader.beginObject(JsonReader.java:469) at c.g.g.i.b.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:509) ... 43 common frames omitted Wrapped by: c.g.g.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 265032 path $.messages[115].attachments[0].list_records[0].fields[1].message See https://github.com/google/gson/blob/main/Troubleshooting.md#unexpected-json-structure at c.g.g.i.b.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:520) at c.g.g.Gson$FutureTypeAdapter.read(Gson.java:1516) at c.g.g.i.b.ReflectiveTypeAdapterFactory$2.readIntoField(ReflectiveTypeAdapterFactory.java:267) at c.g.g.i.b.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:558) at c.g.g.i.b.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:516) at c.g.g.i.b.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) at c.g.g.i.b.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:83) at c.g.g.i.b.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:59) at c.g.g.i.b.ReflectiveTypeAdapterFactory$2.readIntoField(ReflectiveTypeAdapterFactory.java:267) at c.g.g.i.b.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:558) at c.g.g.i.b.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:516) at c.g.g.i.b.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) at c.g.g.i.b.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:83)

rasharab avatar Apr 22 '25 21:04 rasharab

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

github-actions[bot] avatar May 26 '25 00:05 github-actions[bot]

We're hitting this across a few of our customers...

rasharab avatar May 27 '25 23:05 rasharab

Hey @rasharab! 👋 Apologies for lagging on a response here! 😓

At the moment it's not obvious what might be causing this, but I'm wondering if a specific message might be resulting in this that could be used for testing a fix?

A parsing error doesn't seem right for incoming events so I marked this as a "bug" but I also don't have a workaround 🐛

zimeg avatar May 28 '25 01:05 zimeg

🔍 This might be related to https://github.com/slackapi/java-slack-sdk/issues/1468 but that seems to raise a different error due to the size of integers and not unexpected objects...

zimeg avatar May 28 '25 02:05 zimeg

🔍 I'm linking the same and a few other related issues for reference with similar exceptions shared before:

  • https://github.com/slackapi/java-slack-sdk/issues/1426
  • https://github.com/slackapi/java-slack-sdk/issues/1468
  • https://github.com/slackapi/java-slack-sdk/issues/1450
  • https://github.com/slackapi/java-slack-sdk/issues/1454

Edit: Added another issue!

zimeg avatar May 28 '25 02:05 zimeg

It would be nice if we could configure serialization such that it does not deserialize beyond a certain nested depth.

Our company doesn't really care about message attachments for example.

rasharab avatar May 28 '25 03:05 rasharab

we are seeing the same errors

tca3 avatar Jun 06 '25 13:06 tca3