Skip to content

[BUG] CustomItemSerializer causes NullPointerException on ORDER BY queries #12

@samvaity

Description

@samvaity

Describe the bug
When a customItemSerializer is registered on CosmosClientBuilder, queries using ORDER BY fail with a NullPointerException. The issue is that the custom serializer is invoked during internal deserialization of OrderByRowResult, not just for the final application-level object.

Version: com.azure:azure-cosmos:4.70.0
Java: 21

Steps to reproduce:

  1. Register a custom CosmosItemSerializer on CosmosClientBuilder
  2. Execute a query: SELECT * FROM c ORDER BY c.id
  3. The query fails during deserialization

Stack trace:
java.lang.NullPointerException: Cannot invoke Object.getClass() because object is null
at com.azure.cosmos.implementation.query.orderbyquery.OrderByRowResult.getPayload(OrderByRowResult.java:43)
at com.azure.cosmos.implementation.query.OrderByDocumentQueryExecutionContext.lambda(OrderByDocumentQueryExecutionContext.java:695)

Expected: The customItemSerializer should only be called for the final application-level object, not for internal Cosmos SDK structures like OrderByRowResult or Document.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions