{"record":{"id":"224467bcd836fb33","repo":"medusajs/medusa","slug":"invalid-param-rule-type-ruletype","errorCode":null,"errorMessage":"Invalid param rule_type (${ruleType})","messagePattern":"Invalid param rule_type \\((.+?)\\)","errorType":"exception","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/medusa/src/api/admin/promotions/utils/validate-rule-type.ts","lineNumber":9,"sourceCode":"import { MedusaError, RuleType } from \"@medusajs/framework/utils\"\n\nconst validRuleTypes: string[] = Object.values(RuleType)\n\nexport function validateRuleType(ruleType: string) {\n  const underscorizedRuleType = ruleType.split(\"-\").join(\"_\")\n\n  if (!validRuleTypes.includes(underscorizedRuleType)) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `Invalid param rule_type (${ruleType})`\n    )\n  }\n}\n","sourceCodeStart":1,"sourceCodeEnd":15,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/promotions/utils/validate-rule-type.ts#L1-L15","documentation":"Thrown by validateRuleType when the rule_type param, after converting dashes to underscores, is not one of the RuleType enum values. It guards promotion rule endpoints that branch behavior on the rule type.","triggerScenarios":"Passing rule_type=foo, rule_type=bogus, or an unsupported variant (e.g. 'rules-v2') to a promotion rules endpoint that accepts rule_type as a query param.","commonSituations":"Typos in query params, custom UIs sending camelCase instead of snake_case ('ruleType'), or code written against an older/newer RuleType enum that changed values.","solutions":["Check the RuleType enum values in @medusajs/framework/utils (or the API docs) and send a valid one","Normalize params client-side: lowercase and hyphenate before sending","Validate the param in your UI before issuing the request"],"exampleFix":"// before\nGET /admin/promotions/rule-attributes?rule_type=Rule\n\n// after\nGET /admin/promotions/rule-attributes?rule_type=rules // use exact enum value, dashes or underscores accepted","handlingStrategy":"validation","validationCode":"const VALID = Object.values(RuleType) // e.g. [\"rules\",\"rules-v2\",...]\nconst normalized = ruleType.replace(/-/g, \"_\")\nif (!VALID.includes(normalized)) {\n  throw new Error(`rule_type must be one of: ${VALID.join(\", \")}`)\n}","typeGuard":"const isValidRuleType = (t: string) =>\n  Object.values(RuleType).includes(t.replace(/-/g, \"_\"))","tryCatchPattern":"try {\n  await fetchRuleAttributes(ruleType)\n} catch (e: any) {\n  if (e.statusCode === 400 && /rule_type/.test(e.message)) correctParam()\n  else throw e\n}","preventionTips":["Send snake_case or hyphenated enum values exactly as documented","Validate enum query params in the UI before sending","Re-check the RuleType enum after framework upgrades"],"tags":["admin","promotions","validation","query-params"],"backgroundTag":"invalid-request-parameter","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}