[Bug]: 2.7.1 variant deletion workflow
Package.json file
{
"name": "gesa-b2b-commerce-backend",
"version": "0.0.2",
"description": "Medusa 2.x backend",
"author": "Bemind Interactive S.r.l.",
"license": "MIT",
"keywords": [
"sqlite",
"postgres",
"typescript",
"ecommerce",
"headless",
"medusa"
],
"scripts": {
"build": "medusa build && node src/scripts/postBuild.js",
"seed": "medusa exec ./src/scripts/seed.ts",
"ib": "init-backend",
"start": "init-backend && cd .medusa/server && medusa start --verbose",
"dev": "medusa develop",
"email:dev": "email dev --dir=./src/modules/email-notifications/templates --port=3002"
},
"dependencies": {
"@medusajs/admin-sdk": "^2.7.1",
"@medusajs/cli": "^2.7.1",
"@medusajs/dashboard": "^2.7.1",
"@medusajs/event-bus-redis": "^2.7.1",
"@medusajs/framework": "^2.7.1",
"@medusajs/icons": "^2.7.1",
"@medusajs/locking-redis": "^2.7.1",
"@medusajs/medusa": "^2.7.1",
"@medusajs/notification-sendgrid": "^2.7.1",
"@medusajs/payment-stripe": "^2.7.1",
"@medusajs/ui": "^4.0.9",
"@medusajs/utils": "^2.7.1",
"@medusajs/workflow-engine-redis": "^2.7.1",
"@medusajs/workflows-sdk": "^2.7.1",
"@mikro-orm/core": "6.4.3",
"@mikro-orm/knex": "6.4.3",
"@mikro-orm/migrations": "6.4.3",
"@mikro-orm/postgresql": "6.4.3",
"@react-email/components": "^0.0.26",
"@rokmohar/medusa-plugin-meilisearch": "^1.0.3",
"@tanstack/react-table": "^8.21.3",
"@types/turndown": "^5.0.5",
"awilix": "^8.0.1",
"axios": "^1.8.4",
"express-xml-bodyparser": "^0.3.0",
"fast-xml-parser": "^5.2.3",
"medusajs-launch-utils": "^0.0.15",
"meilisearch": "^0.49.0",
"minio": "^8.0.3",
"pg": "^8.13.1",
"react-hook-form": "^7.55.0",
"react-markdown": "^10.1.0",
"redis": "^5.0.1",
"resend": "4.0.1",
"turndown": "^7.2.0",
"ulid": "^2.3.0"
},
"devDependencies": {
"@medusajs/test-utils": "^2.7.1",
"@mikro-orm/cli": "6.4.3",
"@swc/core": "1.5.7",
"@swc/jest": "^0.2.37",
"@types/express-xml-bodyparser": "^0.3.5",
"@types/jest": "^29.5.14",
"@types/node": "^22.14.0",
"jest": "^29.7.0",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-email": "^3.0.4",
"ts-node": "^10.9.2",
"typescript": "^5.8.3",
"vite": "^5.4.11"
},
"packageManager": "[email protected]",
"engines": {
"node": "22.x"
}
}
Node.js version
v22
Database and its version
PostgreSQL 16.3
Operating system name and version
MacOS (Dev) / Linux (Production)
Browser name
Firefox
What happended?
The variant deletion workflow works in reverse: instead of accepting a list of variant IDs to delete, it interprets them as variant IDs to keep.
Consequences
- Cascading deletion of inventory items doesn't occur
- Product details view may break as a result
- Impossible to delete the last variant (generates an empty list of variants to keep)
Temporary workaround
I implemented a solution that:
- Manually handles the deletion of inventory items (passing a list of SKUs to keep) Applies the same approach to variants
- Bulk deletion remains impossible with this approach. When the variant to delete is the last one, an empty keep list is provided to the delete workflow, which results in no action being taken.
Notes
I checked the changelog for version 2.8.0 but there don't appear to be any fixes for this issue.
Expected behavior
The variant deletion workflow should:
- Accept a list of variant IDs to delete (not to keep)
- Properly trigger cascading deletion of associated inventory items
- Allow deletion of the last variant of a product
- Support bulk deletion of all variants when needed
- Maintain referential integrity across the database to prevent breaking the product details view The API should behave consistently with its documentation and naming conventions, where a deletion operation accepts entities to be removed rather than entities to be preserved.
Actual behavior
The variant deletion workflow:
- Interprets the provided list of variant IDs as variants to keep, not variants to delete
- Fails to trigger cascading deletion of associated inventory items
- Creates the need for manual workarounds to maintain data integrity
Link to reproduction repo
https://github.com/gruppo-GESA/gesa-b2b-commerce
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 3 days.
This issue was closed because it has been stalled for 3 days with no activity.