Quantcast
Channel: Square Developer Forums - Latest topics
Viewing all articles
Browse latest Browse all 1325

Catalog Custom Attribute Bug/Feature request - 'enforce_uniqueness' does not work

$
0
0

enforce_uniqueness: true not working in Custom Attributes of Catalog api? It seems the API doc here CatalogCustomAttributeDefinition Object - Square API Reference may not mean what it sounds like it does.

CatalogCustomAttributeDefinitionStringConfig enforce_uniqueness boolean If true, each Custom Attribute instance associated with this Custom Attribute Definition must have a unique value within the seller’s catalog. For example, this may be used for a value like a SKU that should not be duplicated within a seller’s catalog. May not be modified after the definition has been created.

However, I have created via UpsertObject multiple items in the catalog with the same custom attribute. I expected an error to enforce the uniqueness. Reproduction steps:

  1. I created custom attribute definition 6NSCSALZ6QZPJSBBK2VHQTGD, retrieved below by GET /v2/catalog/object/{object_id} - Square API Explorer (object is below)
  2. Upsert object referencing that new custom attribute. (I used the node sdk as well as the api explorer). (only the ITEM_VARIATION has the custom attribute, not the ITEM). Note I upsert with the ITEM with nested ITEM_VARIATION.
  3. Then there are 2 objects with the same custom attribute, no errors, no enforcement of uniqueness. See https://squareup.com/dashboard/items/library/bulk-edit (Note I’d rather have seller visibility read only but that is not an option, so I used SELLER_VISIBILITY_HIDDEN initially but for debugging changed it to SELLER_VISIBILITY_READ_WRITE_VALUES to see it here.
  • Is this how the API is intended to be used?
  • Is there a delay I need between writing and attempting to write again? (Edit: yes I do notice read after write has a delay which has resulted in creating duplicates if I create and try to read too soon).

Here is the custom attribute definition:

{
  "object": {
    "type": "CUSTOM_ATTRIBUTE_DEFINITION",
    "id": "6NSCSALZ6QZPJSBBK2VHQTGD",
    "updated_at": "2023-11-23T04:21:13.844Z",
    "created_at": "2023-11-23T02:42:16.836Z",
    "version": 1700713273844,
    "is_deleted": false,
    "present_at_all_locations": true,
    "custom_attribute_definition_data": {
      "type": "STRING",
      "name": "Full 12 or 13 digit GTIN including checksum, or 4- 5-digit PLU. Must be unique.",
      "description": "UPC-A or EAN-13 (GTIN-12 or GTIN-13) with the checksum and leading zeros or a PLU for produce. One canonical item variation per code in the catalog.",
      "source_application": {
        "application_id": "sq0idp-xxxxxx",
        "name": "xxxxappnamexxxx"
      },
      "allowed_object_types": [
        "ITEM_VARIATION"
      ],
      "seller_visibility": "SELLER_VISIBILITY_READ_WRITE_VALUES",
      "app_visibility": "APP_VISIBILITY_READ_ONLY",
      "string_config": {
        "enforce_uniqueness": true
      },
      "key": "upc_gtin_12_or_13_or_plu"
    }
  }
}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1325

Trending Articles