{"record":{"id":"64ad46d0f5912058","repo":"medusajs/medusa","slug":"rule-value-must-be-an-array-for-in-nin-operators","errorCode":null,"errorMessage":"Rule value must be an array for in/nin operators","messagePattern":"Rule value must be an array for in/nin operators","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/fulfillment/src/utils/utils.ts","lineNumber":131,"sourceCode":"  if (!isString(rule.operator)) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      \"Rule operator must be a string\"\n    )\n  }\n\n  if (!availableOperators.includes(rule.operator as RuleOperator)) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `Rule operator ${\n        rule.operator\n      } is not supported. Must be one of ${availableOperators.join(\", \")}`\n    )\n  }\n\n  if (rule.operator === RuleOperator.IN || rule.operator === RuleOperator.NIN) {\n    if (!Array.isArray(rule.value)) {\n      throw new MedusaError(\n        MedusaError.Types.INVALID_DATA,\n        \"Rule value must be an array for in/nin operators\"\n      )\n    }\n  } else {\n    if (Array.isArray(rule.value) || isObject(rule.value)) {\n      throw new MedusaError(\n        MedusaError.Types.INVALID_DATA,\n        `Rule value must be a string, bool, number value for the selected operator ${rule.operator}`\n      )\n    }\n  }\n\n  return true\n}\n\nexport function normalizeRulesValue<T extends Partial<Rule>>(rules: T[]): void {\n  rules.forEach((rule: any) => {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/fulfillment/src/utils/utils.ts#L113-L149","documentation":"For the in and nin operators the rule value must be an array. Passing a scalar (string/number/bool) throws INVALID_DATA.","triggerScenarios":"rules: [{ attribute: 'iso', operator: 'in', value: 'dk' }] instead of value: ['dk'].","commonSituations":"Copying a single-value eq rule and changing only the operator; form inputs sending a single string where the API expects a list.","solutions":["Wrap the value in an array for in/nin rules","Use eq/neq for single scalar comparisons"],"exampleFix":"// before\nrules: [{ attribute: 'iso', operator: 'in', value: 'dk' }]\n// after\nrules: [{ attribute: 'iso', operator: 'in', value: ['dk', 'se'] }]","handlingStrategy":"validation","validationCode":"if ((rule.operator === 'in' || rule.operator === 'nin') && !Array.isArray(rule.value)) rule.value = [rule.value]","typeGuard":"const isArrayValueForInRule = (r: any): boolean => !(r.operator === 'in' || r.operator === 'nin') || Array.isArray(r.value)","tryCatchPattern":null,"preventionTips":["Auto-wrap scalars for in/nin in your rule builder","Prefer eq for single-value comparisons"],"tags":["fulfillment","rules","validation","array"],"backgroundTag":"schema-validation-failed","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}