Skip to content

[bug]: getObjects JSON deserialization with null object #427

@antoinelapeyrelbo

Description

@antoinelapeyrelbo

Description

Hi,

I'm currently working on an Android application using the Kotlin Algolia client.
I have just updated to 3.5.0 and have an issue when using searchClient.getObjects(): if I request for an object that does not exist on Algolia, it returns an array with some "null" values that breaks the Ktor deserialisation.

For exemple:
The request:
{"requests":[{"objectID":"222966","indexName":"my_index","attributesToRetrieve":[""]},{"objectID":"314558","indexName":"my_index","attributesToRetrieve":[""]},{"objectID":"317683","indexName":"my_index","attributesToRetrieve":[""]}]}
222966 and 317683 exist on Algolia but not 314558
The response:
{"results":[{"objectID":"222966"},null,{"objectID":"317683"}],"message":"ObjectID 314558 does not exist. "}
So it throws and AlgoliaClientException because:
io.ktor.serialization.JsonConvertException: Illegal input: Unexpected JSON token at offset 34: Expected start of the object '{', but had 'n' instead at path: $.results[1]

Is there a way to request for objects even if they don't exist on Algolia and get a response like it did in v2? Maybe using a custom Json deserializer?

Thanks

Client

Search

Version

3.5.0

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions