Skip to content

Sparse Updates Serializing Missing Values Incorrectly #239

Open

Description

@Nathan-Heller

Reproduction Steps

Assuming at least 1 location is present in the environment under test

client = Square::Client.new(token: ENV.fetch('SQUARE_ACCESS_TOKEN'), base_url: Square::Environment::SANDBOX)

location_id = client.locations.list.locations.first.id
order = client.orders.create(idempotency_key: SecureRandom.uuid, order: { location_id: }).order

# this SHOULD do nothing.

client.orders.update(order_id: order.id,
                     idempotency_key: SecureRandom.uuid,
                     order: {})

Expectation

No-op, no exception raised

Observation

Exception gets raised, because location_id is serialized as an empty hash

Square::Errors::ClientError: {"errors": [{"code": "EXPECTED_STRING","detail": "Expected a string value (line 1, character 25)","field": "order.location_id","category": "INVALID_REQUEST_ERROR"}]} (Square::Errors::ClientError)

Notes

This applies to all attributes that are not passed in, not just location_id - e.g. line item quantities is the other attribute tripping our system.

Activity

  1. changed the title [-]Sparse Updates Serializing Msising Values Incorrectly[/-] [+]Sparse Updates Serializing Missing Values Incorrectly[/+] on Oct 21, 2026
  2. cwetherly commented on Oct 21, 2026

    @cwetherly
    Contributor

    Taking a look

  3. cwetherly commented on Oct 21, 2026

    @cwetherly
    Contributor

    Ok reproduced, working on a fix

  4. Nathan-Heller commented on Oct 30, 2026

    @Nathan-Heller
    Author

    this can be closed, the issue is resolved. thanks again @cwetherly

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