#1070 — Spurious ‘Merchant details updated’ for empty inventory on no-op update

Repo: Twill-AI/facade State: closed | Status: done Assignee: nadddder

Created: 2026-02-26 · Updated: 2026-03-06

Description

Summary

When a merchant is first created, the inventory field is empty (NULL in DB). If a user then hits “update” without changing any fields, the client often sends the default empty inventory payload (e.g. {"equipment":[],"requestConsult":false}). The activity diff treats this as a change and creates a “Merchant details updated” activity showing:

  • Inventory: Empty → {"equipment":[],"requestConsult":false}

So a no-op update produces a misleading activity entry.

Current behavior

  • DB: DbMerchant.inventory is Text(null=True, default=None) (app/db/master_tables.py ~368). New merchants have inventory = NULL.
  • Update diff: In app/api/merchants_helpers.py (~817–838), the diff compares old_value = getattr(existing_merchant, key) with new_value from merchant_updates using old_value != new_value. There is no special handling for inventory.
  • So when old_value is None (or "") and new_value is the string '{"equipment":[],"requestConsult":false}', the diff records a change and an activity is created.

Proposed fix

  1. Normalize “empty” inventory in the diff
    • When computing the activity diff for the inventory field, treat the following as equivalent (no change):
      • None
      • ""
      • JSON string that parses to an object with empty equipment and requestConsult: false, e.g. {"equipment":[],"requestConsult":false} (and common variants, e.g. different key order or whitespace).
    • Only record an “inve

Notes

Add implementation notes, blockers, and context here

Add wikilinks to related people, meetings, or other tickets