Skip to content

[Bug]: currency_code validation on create product route does not enforce lowercase #13956

@enable-davidlin

Description

@enable-davidlin

Package.json file

{
  "name": "medusa-b2b-starter",
  "version": "0.0.1",
  "description": "A starter for Medusa B2B projects.",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "keywords": [
    "sqlite",
    "postgres",
    "typescript",
    "ecommerce",
    "headless",
    "medusa"
  ],
  "scripts": {
    "build": "medusa build",
    "seed": "medusa exec ./src/scripts/seed.ts",
    "start": "medusa start",
    "dev": "medusa develop",
    "test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit"
  },
  "dependencies": {
    "@medusajs/admin-sdk": "2.11.1",
    "@medusajs/cli": "2.11.1",
    "@medusajs/framework": "2.11.1",
    "@medusajs/js-sdk": "2.11.1",
    "@medusajs/medusa": "2.11.1"
  },
  "devDependencies": {
    "@medusajs/test-utils": "2.11.1",
    "@swc/core": "^1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/jest": "^29.5.14",
    "@types/node": "^20.0.0",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "^29.7.0",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "vite": "^5.2.11"
  },
  "engines": {
    "node": ">=20"
  }
}

Node.js version

v21.7.2

Database and its version

PostgreSQL 17

Operating system name and version

macOS 15.6.1

Browser name

No response

What happended?

When creating a product through the Admin API, passing the currency_code in uppercase still succeeds, but breaks everything else because it also gets stored in the DB as uppercase, but all other workflows match it case-sensitive.

Expected behavior

Both passing lowercase and uppercase currency_code should succeed. enforce lowercase by transforming the input to lowercase.

Actual behavior

Passing uppercase currency_code succeeds, but stores it as uppercase in the DB. Workflows match case-sensitive and expects lowercase, which breaks everything.

Link to reproduction repo

Running npx create-medusa-app@latest my-medusa-store

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions