Skip to content

Avro.decodeFromByteArray can throw AvroRuntimeException and UnsupportedOperationException #269

Open
@felixwiemuth

Description

Describe the bug
According to the docs, Avro.decodeFromByteArray can only throw SerializationException and IllegalArgumentException.
However, when testing with some malformatted input data, I came accross two cases where other exceptions were thrown:

  • UnsupportedOperationException: cannot read strings longer than 2147483639 bytes
  • AvroRuntimeException: Malformed data. Length is negative: -62

These seem to be normal deserialization exceptions, where some data is interpreted as lengths etc.

All exceptions due to a malformatted input should result in a SerializationException (which I think is the intended exception in the design of the library).

To Reproduce

Experiment with some random data.
If needed, I can try to give some examples.
But regarding the exception messages provided above, it should probably be straight-forward to find the place where they are thrown.
It'll probably be a good idea to add some randomized tests, which call decoding with randomized bytes, to see whether the right exceptions are thrown.

Expected behavior
SerializationException should be throw for all deserialization-caused exceptions.

Desktop (please complete the following information):

  • Kotlin version: 2.1.0
  • Avro4k version: 2.1.1
  • Other kotlinx-version: 1.8.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions