medusajs/medusa · error · Error

Cannot set value for .

Error message

Cannot set value ${value} for ${columnName}.

What it means

A mikro-orm property decorator for BigNumber-typed columns. When constructing BigNumber from the incoming value throws (unparseable string, NaN, invalid object), the catch rethrows with the offending value and column name.

Solutions

  1. Sanitize numeric strings before assignment (strip commas/symbols, validate with a regex)
  2. Coerce to number and check Number.isFinite before setting the field
  3. Fix the data producer to send plain numbers or plain numeric strings

Example fix

// before
variant.prices.push({ amount: "1.299,00", currency_code: "eur" })
// after
const amount = Number(priceRaw.replace(/[^0-9.-]/g, ""))
if (!Number.isFinite(amount)) throw new Error(`Bad price: ${priceRaw}`)
variant.prices.push({ amount, currency_code: "eur" })
Defensive patterns

Strategy: validation

Validate before calling

const n = typeof v === 'number' ? v : Number(String(v).replace(/[^0-9.\-]/g, ''))
if (!Number.isFinite(n)) throw new Error(`non-numeric amount: ${v}`)

Type guard

const isFiniteNumber = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v)

Try / catch

try { await manager.persistAndFlush(entity) } catch (e) { if (/Cannot set value/.test(e.message)) sanitize the offending field and retry once; else throw e }

Prevention

When it happens

Trigger: Assigning a string like "12,00" or "abc" to a raw_amount/money field, or NaN from a computed price, when persisting entities via upsert/upsertWithReplace in product/order/pricing modules.

Common situations: CSV/product imports with locale-formatted numbers, JSON payloads using strings with currency symbols, or arithmetic producing NaN before assignment.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/ce053e606132a92c. Report an issue: GitHub.

Appendix: source

Thrown at packages/core/utils/src/dal/mikro-orm/big-number-field.ts:58

            this.__helper.__data[columnName] = undefined
            this.__helper.__data[rawColumnName] = undefined
            this[rawColumnName] = undefined
          } else {
            let bigNumber: BigNumber

            try {
              if (value instanceof BigNumber) {
                bigNumber = value
              } else if (this[rawColumnName]) {
                const precision = this[rawColumnName].precision
                bigNumber = new BigNumber(value, {
                  precision,
                })
              } else {
                bigNumber = new BigNumber(value)
              }
            } catch (e) {
              throw new Error(`Cannot set value ${value} for ${columnName}.`)
            }

            const raw = bigNumber.raw!
            raw.value = trimZeros(raw.value as string)

            // Note: this.__helper isn't present when directly working with the entity
            // Adding this in optionally for it not to break.
            if (isDefined(this.__helper)) {
              this.__helper.__data[columnName] = bigNumber.numeric
              this.__helper.__data[rawColumnName] = raw
            }

            this[rawColumnName] = raw
          }
        }

        // Note: this.__helper isn't present when directly working with the entity
        // Adding this in optionally for it not to break.

View on GitHub (pinned to 5e06e544a2)