Skip to content

Add null-safe comparisons in model Equals methods #124

@coderabbitai

Description

@coderabbitai

Description

Several model classes in the SDK contain Equals methods that may throw NullReferenceException when comparing nullable properties. The current pattern uses:

this.Property == input.Property || this.Property.Equals(input.Property)

This will throw if this.Property is null and input.Property is non-null.

Affected Classes

Known affected models:

  • WriteRequestWrites (OnDuplicate property)
  • WriteRequestDeletes (OnMissing property)

All other model classes with nullable properties should be audited for similar issues.

Proposed Fix

Replace unsafe comparisons with null-safe alternatives:

object.Equals(this.Property, input.Property)

Or:

this.Property == input.Property || (this.Property \!= null && this.Property.Equals(input.Property))

Context

Identified during review of PR #120.

Referenced by: @rhamzeh

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions