boopickle icon indicating copy to clipboard operation
boopickle copied to clipboard

Unknown integer coding error

Open ioleo opened this issue 1 year ago • 5 comments

In one of the responses I return a raw token:

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIwMUgwRFFUOTA1UzJOMlI1Q0s3RDNLRzlaOSIsImlzcyI6ImtpcmluIiwiaWF0IjoxNjg0MDg4MzY2LCJleHAiOjE2ODQxNzQ3NjYsInJvbGVzIjpbImFjY2Vzc1Rva2VuIiwidXNlciIsImFkbWluIl0sInVzZXJJZCI6IjAxSDBESDZFN1hTUENQRDEyTU5WS0dKNFhOIn0.VDj6WivUEFZZPB_Z8kMnQJTR2S3AJDm7o_juxMvScwc

which for some reason, when deserializing on frontend, triggers this error:

DeserializerError(java.lang.IllegalArgumentException: Unknown integer coding)

Experimenting a little, I think this is because the string is so long. By trial and error I determined that a 127-characters long string is OK, anything larger triggers the error.

source

ioleo avatar May 14 '23 18:05 ioleo

As a workaround, I'm doing rawToken.grouped(120).toList, the API then takes a List[String] instead, and on frontend side I do rawTokenParts.mkString. Works.

ioleo avatar May 14 '23 18:05 ioleo

I got into the same issue again. This time I had:

case class UserView(
  // ...
  roles: List[String]
)

and users fetched from database had either user or admin roles (note: both short strings, shorter than 127 chars). Yet I got the same deserializer error.

Trying other collections like Vector does not help either.

Any ideas what this might be? /cc @ochrons @japgolly

ioleo avatar Jul 27 '23 21:07 ioleo

I wonder why readInt gets invoked when my case class does not have any Int fields?

/cc @cquiroz

ioleo avatar Aug 06 '23 16:08 ioleo

I don't have much to add to this. I've used boopickle a lot with property tests (which generates massive strings) and I've never seen it fail. If you could provide a reproduction, a failing test case, that would really help.

I wonder why readInt gets invoked when my case class does not have any Int fields?

Encoders for other formats will serialise ints. Eg. string length and list length.

japgolly avatar Aug 06 '23 22:08 japgolly

I got into the same issue again. This time I had:

Usually, I have seen these kind of errors, when the wrong codec is used for decoding in the frontend. Like, you might be returning an error message in the backend and the frontend wants to decode it as a success. Do you have more logs for these events? Or can you somehow reproduce it in a contained example?

cornerman avatar Aug 07 '23 11:08 cornerman