{"record":{"id":"bea602fb97fa2a17","repo":"medusajs/medusa","slug":"rule-attribute-must-be-a-string","errorCode":null,"errorMessage":"Rule attribute must be a string","messagePattern":"Rule attribute must be a string","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/fulfillment/src/utils/utils.ts","lineNumber":107,"sourceCode":"  }\n\n  return loopComparator.apply(rules, [predicate])\n}\n\n/**\n * Validate contextValue rule object\n * @param rule\n */\nexport function validateRule(rule: Record<string, unknown>): boolean {\n  if (!rule.attribute || !rule.operator || !rule.value) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      \"Rule must have an attribute, an operator and a value\"\n    )\n  }\n\n  if (!isString(rule.attribute)) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      \"Rule attribute must be a string\"\n    )\n  }\n\n  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(\", \")}`","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/fulfillment/src/utils/utils.ts#L89-L125","documentation":"Within validateRule, the rule's attribute must be a string. Passing a number, object, or symbol as attribute throws INVALID_DATA.","triggerScenarios":"Programmatically building rules with computed keys or unserialized values, e.g. { attribute: 123, ... } or attribute taken from untyped JSON input.","commonSituations":"CSV/external imports mapping columns to attributes without coercing to string; client sending numeric attribute identifiers.","solutions":["Coerce/validate attribute to a string before calling the service","Use known attribute identifiers as string constants"],"exampleFix":"// before\nrules: [{ attribute: 42, operator: 'eq', value: 'x' }]\n// after\nrules: [{ attribute: String(42), operator: 'eq', value: 'x' }])","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"const hasStringAttribute = (r: any): boolean => typeof r?.attribute === 'string' && r.attribute.length > 0","tryCatchPattern":null,"preventionTips":["Type rule inputs as { attribute: string; operator: string; value: unknown }","Coerce imported values with String() before building rules"],"tags":["fulfillment","rules","type-validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}