Skip to content

[Cosmos] Audit RxDocumentServiceRequest.clone() for missing field copies #48496

@jeet1995

Description

@jeet1995

Problem

RxDocumentServiceRequest.clone() does not copy all fields. This was discovered during PR #48432 where partitionKeyDefinition was missing from the clone, causing NPE in hedged thin client queries.

A field-by-field audit reveals ~12 other fields that are not copied by clone():

  • effectivePartitionKey
  • properties (carries excludedRegions and request-scoped metadata)
  • throughputControlGroupName
  • responseTimeout
  • entityId
  • and others

Impact

For hedging scenarios (where clone() is used), the cloned request silently loses these properties. The properties map is particularly concerning since it carries excludedRegions -- a hedged request could target an excluded region.

Proposed Fix

  1. Audit every field in RxDocumentServiceRequest against clone()
  2. Add missing field copies
  3. Add a reflection-based completeness test that fails when a new field is added to the class but not included in clone() -- this prevents future regressions

Context

  • Reported in PR #48432 review by @xinlian12
  • Related to [GATEWAY V2] thin client availability strategy work
  • clone() is a maintenance trap -- every new field silently breaks hedging until someone discovers a bug
  • The reflection-based test would make this self-enforcing

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions