Resolving Price Update Errors in ESHOPMAN Admin: The Empty Rules Object Bug

At Move My Store, we closely monitor the ESHOPMAN community for insights that empower our users. A recent discussion highlighted a critical issue impacting price list management within the ESHOPMAN Admin dashboard, particularly for those running version 2.17.2 or later. This insight delves into the details of a bug causing HTTP 500 errors when updating existing plain currency prices, affecting storefront management directly from HubSpot.

The ESHOPMAN Price Update Challenge: A Deep Dive

Users have reported encountering a persistent HTTP 500 error when attempting to modify the amount of an existing price list price through the ESHOPMAN Admin dashboard. While creating new prices works seamlessly, updates to already-saved plain currency prices (those without region or quantity rules) consistently fail. This issue has significant implications for merchants managing their product catalog and pricing strategies within their HubSpot-integrated storefronts.

Understanding the Root Cause

Our community's detailed analysis traced the problem to a specific change introduced in ESHOPMAN version 2.17.2, stemming from a feature enhancement related to tiered pricing. Here's a breakdown of the technical flow:

  1. Admin UI Payload Change: After the update, the ESHOPMAN Admin dashboard's edit form now consistently attaches a rules object to every updated price. For a plain currency price, this object is empty ({}). Previously, for such prices, the rules key would simply be absent or undefined in the request payload.
  2. Core Pricing Module Behavior: ESHOPMAN's core pricing module, responsible for normalizing prices, includes a check (isPresent(price.rules)) to determine if rules should be processed and, crucially, if the rules key should be stripped before persisting the data. However, isPresent({}) evaluates to FALSE. This means that for an empty rules object, the logic to remove the stray rules key from the entity data is never triggered.
  3. Database Layer Conflict: The entity, now containing an unexpected rules property, is passed to ESHOPMAN's underlying data access layer. When updating existing rows, this process attempts to map the unknown rules property, leading to a TypeError: Cannot read properties of undefined (reading 'fieldNames'). New prices are unaffected because their insertion path only maps known columns, bypassing this specific update conflict.

This behavior is consistent across various update scenarios:

  • Updating without the rules key: 200 OK
  • Updating with rules: {}: 500 Error (this bug)
  • Updating with rules: {"region_id": "..."}: 200 OK (non-empty rules are converted properly)

Impact on ESHOPMAN Merchants and Developers

For merchants, this bug effectively renders plain currency prices uneditable via the HubSpot storefront management UI, forcing workarounds or delaying critical price adjustments. Developers interacting with the ESHOPMAN Admin API (POST /admin/price-lists/:id/prices/batch) will also encounter 500 errors if their update payloads include an empty rules: {} object for plain prices.

Technical Snippets from the Discussion

The community pinpointed the exact code areas contributing to the issue. Here's a simplified view of the logic that changed and the subsequent processing:

// Admin UI payload construction (simplified)
pricesToUpdate.push({
  id, variant_id, currency_code, amount,
  rules: {
    ...(newPrice.regionId ? { region_id: newPrice.regionId } : {}),
    // ... other rules
  },   // <- {} for a plain currency price in v2.17.2+
})

// ESHOPMAN's core pricing module (simplified)
const hasRulesInput = isPresent(price.rules)
if (hasRulesInput) {
  entry.price_rules = rules
  entry.rules_count = rules.length
  delete entry.rules        // <- never reached for rules: {}
}

The expected behavior is that an empty rules object should be treated identically to an absent or undefined one, ensuring smooth price updates. The community has acknowledged this issue, and a fix is anticipated to restore full functionality to price management within ESHOPMAN.

Stay tuned to Move My Store for further updates and best practices to optimize your ESHOPMAN headless commerce experience integrated with HubSpot.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools