{"record":{"id":"e1841fa6cce2c9c6","repo":"medusajs/medusa","slug":"invalid-data-e1841f","errorCode":"invalid_data","errorMessage":"invalidOperatorError","messagePattern":"invalidOperatorError","errorType":"exception","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/pricing/src/services/pricing-module.ts","lineNumber":938,"sourceCode":"    const existingPricesMap = new Map<string, PricingTypes.PriceDTO>()\n    Array.from(existingPrices ?? []).forEach((price) => {\n      existingPricesMap.set(hashPrice(price), price)\n    })\n\n    const ruleOperatorsSet = new Set<PricingRuleOperatorValues>(\n      Object.values(PricingRuleOperator)\n    )\n    const validOperatorsList = Array.from(ruleOperatorsSet).join(\", \")\n    const invalidOperatorError = `operator should be one of ${validOperatorsList}`\n\n    data?.forEach((price) => {\n      const cleanRules = price.rules ? removeNullish(price.rules) : {}\n\n      const rules = Object.entries(cleanRules).flatMap(([attribute, value]) => {\n        if (Array.isArray(value)) {\n          return value.map((customRule) => {\n            if (!ruleOperatorsSet.has(customRule.operator)) {\n              throw new MedusaError(\n                MedusaError.Types.INVALID_DATA,\n                invalidOperatorError\n              )\n            }\n\n            if (typeof customRule.value !== \"number\") {\n              throw new MedusaError(\n                MedusaError.Types.INVALID_DATA,\n                `value should be a number`\n              )\n            }\n\n            return {\n              attribute,\n              operator: customRule.operator,\n              // TODO: we throw above if value is not a number, but the model expect the value to be a string\n              value: customRule.value.toString(),\n            }","sourceCodeStart":920,"sourceCodeEnd":956,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/pricing/src/services/pricing-module.ts#L920-L956","documentation":"When upserting price list rules with array values, each rule object must carry an operator that exists in the allowed rule operator set (e.g. 'eq', 'gt', 'lt', 'gte', 'lte', 'in'...). Using an unknown operator throws INVALID_DATA with the shared invalidOperatorError message.","triggerScenarios":"Calling updatePriceListRules / addPriceListRules-style APIs (upserting prices with rules) where a rule value is an array of { operator, value } objects and operator is misspelled or unsupported, e.g. 'equals' instead of 'eq'.","commonSituations":"Porting code from an older Medusa version where rules were plain key-value maps, guessing operator names, or string typos in dynamic rule building.","solutions":["Use only supported operators (eq, ne, gt, gte, lt, lte, in) — check ruleOperatorsSet in the pricing module for the exact list","Fix typos such as 'equals' → 'eq' or '>=' → 'gte'","If building rules dynamically, validate the operator against an allowlist before calling the API"],"exampleFix":"// before\nrules: { region_id: [{ operator: 'equals', value: 'reg_123' }] }\n\n// after\nrules: { region_id: [{ operator: 'eq', value: 'reg_123' }] }","handlingStrategy":"validation","validationCode":"const ALLOWED_OPERATORS = ['eq','ne','gt','gte','lt','lte','in'] as const\nconst normalizeOperator = (op: string) =>\n  ({ equals: 'eq', '=': 'eq', '>=': 'gte', '<=': 'lte' } as Record<string,string>)[op] ?? op\n\nconst rules = Object.fromEntries(\n  Object.entries(rawRules).map(([k, v]) => [\n    k,\n    Array.isArray(v)\n      ? v.map((r) => ({ ...r, operator: normalizeOperator(r.operator) }))\n      : v,\n  ])\n)\n// verify before calling\nfor (const v of Object.values(rules)) {\n  if (Array.isArray(v)) v.forEach((r) => {\n    if (!ALLOWED_OPERATORS.includes(r.operator)) throw new Error(`Bad operator: ${r.operator}`)\n  })\n}","typeGuard":"const isRuleOperator = (op: unknown): op is 'eq'|'ne'|'gt'|'gte'|'lt'|'lte'|'in' =>\n  typeof op === 'string' && ['eq','ne','gt','gte','lt','lte','in'].includes(op)","tryCatchPattern":null,"preventionTips":["Centralize rule-building in one helper with an operator allowlist","Add a unit test enumerating supported operators"],"tags":["pricing","validation","operators","rules"],"backgroundTag":"invalid-enum-value","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}