medusajs/medusa

[Bug]: Creating a return in the admin backoffice and adding items multiple times while letting previous items selected duplicate line in the return object

Open

Aperta il 25 mar 2026

Vedi su GitHub
 (8 commenti) (0 reazioni) (0 assegnatari)TypeScript (22.539 star) (2090 fork)batch import
good first issuetype: bugversion: 2.0

Descrizione

Package.json file

{
  "name": "my-project",
  "version": "0.0.38",
  "description": "My Project",
  "scripts": {
    "build": "medusa build",
    "predeploy": "medusa db:migrate",
    "seed": "medusa exec ./src/scripts/seed.ts",
    "test:smtp": "medusa exec ./src/scripts/test-smtp.ts",
    "start": "medusa start",
    "dev": "medusa develop",
    "deploy:staging": "./scripts/deploy-staging.sh",
    "deploy:production": "./scripts/deploy-production.sh",
    "test": "yarn test:unit",
    "test:ci": "COVERAGE=true TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --maxWorkers=50% --forceExit",
    "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 --maxWorkers=50% --forceExit",
    "test:unit:watch": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --watch --maxWorkers=25%",
    "type-check": "tsc --noEmit",
    "lint": "yarn quality",
    "lint:fix": "biome lint --write .",
    "format": "biome format --write .",
    "format:check": "biome format .",
    "check": "biome check .",
    "check:fix": "biome check --write .",
    "quality": "biome ci ."
  },
  "dependencies": {
    "@aws-sdk/client-dynamodb": "^3.0.0",
    "@medusajs/admin-sdk": "2.13.1",
    "@medusajs/auth": "2.13.1",
    "@medusajs/auth-emailpass": "2.13.1",
    "@medusajs/auth-google": "2.13.1",
    "@medusajs/caching-redis": "^2.13.4",
    "@medusajs/cli": "2.13.1",
    "@medusajs/draft-order": "2.13.1",
    "@medusajs/framework": "2.13.1",
    "@medusajs/index": "2.13.1",
    "@medusajs/medusa": "2.13.1",
    "ajv": "^8.17.1",
    "ajv-formats": "^3.0.1",
    "algoliasearch": "5.39.0",
    "cronstrue": "^3.12.0",
    "dayjs": "^1.11.18",
    "fast-xml-parser": "^5.3.6",
    "json-rules-engine": "^7.3.1",
    "jsonwebtoken": "^9.0.2",
    "nodemailer": "^7.0.11"
  },
  "devDependencies": {
    "@biomejs/biome": "2.0.6",
    "@medusajs/test-utils": "2.13.1",
    "@swc/core": "1.5.7",
    "@swc/jest": "0.2.39",
    "@types/ajv": "^0.0.5",
    "@types/jest": "30.0.0",
    "@types/jsonwebtoken": "^9.0.10",
    "@types/node": "^22.0.0",
    "@types/nodemailer": "^7.0.4",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "30.2.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "ts-node": "^10.9.2",
    "typescript": "5.9.3",
    "vite": "^5.4.21",
    "yalc": "^1.0.0-pre.53"
  },
  "optionalDependencies": {
    "@biomejs/cli-linux-x64-musl": "2.0.6",
    "@rollup/rollup-darwin-arm64": "4.43.0",
    "@rollup/rollup-darwin-x64": "4.43.0",
    "@rollup/rollup-linux-arm64-gnu": "4.43.0",
    "@rollup/rollup-linux-arm64-musl": "4.43.0",
    "@rollup/rollup-linux-x64-musl": "4.43.0"
  },
  "engines": {
    "node": ">=24.1.0"
  },
  "volta": {
    "node": "24.1.0",
    "yarn": "4.12.0"
  },
  "overrides": {
    "axios": "1.13.5",
    "glob": "11.1.0",
    "immutable": "4.3.8",
    "jws": "4.0.1",
    "multer": "2.1.1",
    "qs": "6.14.1",
    "rollup": "4.59.0",
    "tar": "7.5.11",
    "@isaacs/brace-expansion": "5.0.1",
    "fast-xml-parser": "5.3.6",
    "minimatch@^10.1.1": "10.2.3"
  },
  "resolutions": {
    "tar": "7.5.11",
    "@isaacs/brace-expansion": "5.0.1",
    "fast-xml-parser": "5.3.6",
    "axios": "1.13.5",
    "immutable": "4.3.8",
    "multer": "2.1.1",
    "rollup": "4.59.0",
    "minimatch@^10.1.1": "10.2.3"
  },
  "packageManager": "yarn@4.12.0"
}

Node.js version

24.1.X

Database and its version

Medusa Cloud

Operating system name and version

Medusa Cloud

Browser name

Google Chrome

What happended?

When i want to create a return using the MedusaJS Admin UI in the order details, if i "Add items" and select a product then i try to "Add items" again and I let my previous product selected, it will show only 1 product of each product selected on the Inbound popup display but it will create a second entry of this items in the activity but not in the item summary.

Initiate a return :

Add your item :

Click on "Add items" again and click on "Save" letting the previous selected item as is :

Confirm your return : In the product summary, you only see one return but in the activity you see two return of the items items

[
    {
        "id": "return_01KMHZBN5TJM5GDJB9SX0FGY9B",
        "order_id": "order_01KKET9JFKBF0XRCEQYCAQTCJP",
        "display_id": 156,
        "location_id": "sloc_01K772R4KFVWSTXVNXCXAEG7FS",
        "order_version": 3,
        "status": "requested",
        "metadata": null,
        "no_notification": null,
        "refund_amount": null,
        "created_by": "user_01K5XENA4ZB0465RXTP6MCWCQC",
        "created_at": "2026-03-25T07:46:46.586Z",
        "updated_at": "2026-03-25T07:50:28.741Z",
        "canceled_at": null,
        "requested_at": "2026-03-25T07:50:28.710Z",
        "received_at": null,
        "items": [
            {
                "id": "retitem_01KMHZJE3067MWP8CA7WH17PGH",
                "note": null,
                "metadata": {},
                "reason_id": null,
                "return_id": "return_01KMHZBN5TJM5GDJB9SX0FGY9B",
                "item_id": "ordli_01KKET9JFK04JF8JH0PK3XGK2H",
                "raw_quantity": {
                    "value": "1",
                    "precision": 20
                },
                "raw_received_quantity": {
                    "value": "0",
                    "precision": 20
                },
                "raw_damaged_quantity": {
                    "value": "0",
                    "precision": 20
                },
                "created_at": "2026-03-25T07:50:28.704Z",
                "updated_at": "2026-03-25T07:50:28.704Z",
                "deleted_at": null,
                "reason": null,
                "item": {
                    "id": "ordli_01KKET9JFK04JF8JH0PK3XGK2H"
                },
                "quantity": 1,
                "received_quantity": 0,
                "damaged_quantity": 0
            },
            {
                "id": "retitem_01KMHZJE30XP9M04BQHSDS8SJV",
                "note": null,
                "metadata": {},
                "reason_id": null,
                "return_id": "return_01KMHZBN5TJM5GDJB9SX0FGY9B",
                "item_id": "ordli_01KKET9JFK04JF8JH0PK3XGK2H",
                "raw_quantity": {
                    "value": "1",
                    "precision": 20
                },
                "raw_received_quantity": {
                    "value": "0",
                    "precision": 20
                },
                "raw_damaged_quantity": {
                    "value": "0",
                    "precision": 20
                },
                "created_at": "2026-03-25T07:50:28.704Z",
                "updated_at": "2026-03-25T07:50:28.704Z",
                "deleted_at": null,
                "reason": null,
                "item": {
                    "id": "ordli_01KKET9JFK04JF8JH0PK3XGK2H"
                },
                "quantity": 1,
                "received_quantity": 0,
                "damaged_quantity": 0
            }
        ]
    }
]

Expected behavior

The inbound display only one of each selected item :

And the return object should only reflect the inbound display and only have one item line

Actual behavior

The inbound display only one item but it will make 2 lines inside the return object if you add the same items again but it only show one inbound item in the display :

[
    {
        "id": "return_01KMHZBN5TJM5GDJB9SX0FGY9B",
        "order_id": "order_01KKET9JFKBF0XRCEQYCAQTCJP",
        "display_id": 156,
        "location_id": "sloc_01K772R4KFVWSTXVNXCXAEG7FS",
        "order_version": 3,
        "status": "requested",
        "metadata": null,
        "no_notification": null,
        "refund_amount": null,
        "created_by": "user_01K5XENA4ZB0465RXTP6MCWCQC",
        "created_at": "2026-03-25T07:46:46.586Z",
        "updated_at": "2026-03-25T07:50:28.741Z",
        "canceled_at": null,
        "requested_at": "2026-03-25T07:50:28.710Z",
        "received_at": null,
        "items": [
            {
                "id": "retitem_01KMHZJE3067MWP8CA7WH17PGH",
                "note": null,
                "metadata": {},
                "reason_id": null,
                "return_id": "return_01KMHZBN5TJM5GDJB9SX0FGY9B",
                "item_id": "ordli_01KKET9JFK04JF8JH0PK3XGK2H",
                "raw_quantity": {
                    "value": "1",
                    "precision": 20
                },
                "raw_received_quantity": {
                    "value": "0",
                    "precision": 20
                },
                "raw_damaged_quantity": {
                    "value": "0",
                    "precision": 20
                },
                "created_at": "2026-03-25T07:50:28.704Z",
                "updated_at": "2026-03-25T07:50:28.704Z",
                "deleted_at": null,
                "reason": null,
                "item": {
                    "id": "ordli_01KKET9JFK04JF8JH0PK3XGK2H"
                },
                "quantity": 1,
                "received_quantity": 0,
                "damaged_quantity": 0
            },
            {
                "id": "retitem_01KMHZJE30XP9M04BQHSDS8SJV",
                "note": null,
                "metadata": {},
                "reason_id": null,
                "return_id": "return_01KMHZBN5TJM5GDJB9SX0FGY9B",
                "item_id": "ordli_01KKET9JFK04JF8JH0PK3XGK2H",
                "raw_quantity": {
                    "value": "1",
                    "precision": 20
                },
                "raw_received_quantity": {
                    "value": "0",
                    "precision": 20
                },
                "raw_damaged_quantity": {
                    "value": "0",
                    "precision": 20
                },
                "created_at": "2026-03-25T07:50:28.704Z",
                "updated_at": "2026-03-25T07:50:28.704Z",
                "deleted_at": null,
                "reason": null,
                "item": {
                    "id": "ordli_01KKET9JFK04JF8JH0PK3XGK2H"
                },
                "quantity": 1,
                "received_quantity": 0,
                "damaged_quantity": 0
            }
        ]
    }
]

Link to reproduction repo

https://github.com/medusajs/medusa

Guida contributor