Skip to content

bug(realtime): array converters throw past their catch on a JSON array with a bad element #437

Description

@fresh55

IntArrayConverter and StringArrayConverter return null for anything they cannot read, but only on the string-literal path. On the JSON path a failing element leaves the reader half way through the array, and an object in place of the array is never consumed, so System.Text.Json throws "read too much or not enough" after Read returns and the whole record fails in Model<T>().

{"favorite_numbers":[1,"x"]}   // JsonException, record lost
{"favorite_numbers":{}}        // same
{"favorite_numbers":"{1,x}"}   // null, as intended

Fix is the one PostgresNestedArrayConverter got in #436: copy the reader before the try, and in the catch rewind it and Skip(); Skip() in the default branch too.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions