medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
25.98k stars 2.61k forks source link

[Bug]: Cannot update order [admin api] #10130

Open kingwill101 opened 1 day ago

kingwill101 commented 1 day ago

Package.json file

{
  "name": "medusa-starter-default",
  "version": "0.0.1",
  "description": "A starter for Medusa 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": "latest",
    "@medusajs/cli": "latest",
    "@medusajs/framework": "latest",
    "@medusajs/medusa": "latest",
    "@mikro-orm/core": "5.9.7",
    "@mikro-orm/knex": "5.9.7",
    "@mikro-orm/migrations": "5.9.7",
    "@mikro-orm/postgresql": "5.9.7",
    "awilix": "^8.0.1",
    "pg": "^8.13.0"
  },
  "devDependencies": {
    "@medusajs/test-utils": "latest",
    "@mikro-orm/cli": "5.9.7",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/jest": "^29.5.13",
    "@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

v20.11.1

Database and its version

postgres (PostgreSQL) 15.6

Operating system name and version

Linux

Browser name

No response

What happended?

Trying to update an order

curl --location 'http://localhost:9000/admin/orders/order_01JCXKEG7XNKSRK8T671FF17AJ' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY3Rvcl9pZCI6InVzZXJfMDFKQTBIUVNWTjZWNTA1MEdNUzg4NUhRTUQiLCJhY3Rvcl90eXBlIjoidXNlciIsImF1dGhfaWRlbnRpdHlfaWQiOiJhdXRoaWRfMDFKQTBIUVQxRlJNWlpRMVA1WFJBVjZXRkEiLCJhcHBfbWV0YWRhdGEiOnsidXNlcl9pZCI6InVzZXJfMDFKQTBIUVNWTjZWNTA1MEdNUzg4NUhRTUQifSwiaWF0IjoxNzMxODMzNDUxLCJleHAiOjE3MzE5MTk4NTF9.eE7sqsoEsKCO-sRPcIYeo8LZMVolFdyKvCFL-ra8zq0' \
--header 'Cookie: connect.sid=s%3APG3t3hFJDPkyNmVyhSX3ZrqnZ0pIwQrl.yh2fluxsr1%2BiOh%2Ffmt0MgPHV0sxjF44JL%2FUe7gYSazI' \
--data-raw '{
  "email": "new-email@example.com",
  "shipping_address": {
    "first_name": "John",
    "last_name": "Doe",
    "address_1": "123 Main St",
    "city": "New York",
    "country_code": "US",
    "postal_code": "10001"
  }
}'```

### Expected behavior

order is updated with the post data

### Actual behavior

error: Cannot read properties of undefined (reading 'fields') TypeError: Cannot read properties of undefined (reading 'fields') at POST (/home/kingwill101/code/capcom-proj/capcom/node_modules/@medusajs/medusa/src/api/admin/orders/[id]/route.ts:42:35) at /home/kingwill101/code/capcom-proj/capcom/node_modules/@medusajs/utils/src/common/wrap-handler.ts:17:20 at Layer.handle [as handle_request] (/home/kingwill101/code/capcom-proj/capcom/node_modules/express/lib/router/layer.js:95:5) at next (/home/kingwill101/code/capcom-proj/capcom/node_modules/express/lib/router/route.js:149:13) at Route.dispatch (/home/kingwill101/code/capcom-proj/capcom/node_modules/express/lib/router/route.js:119:3) at Layer.handle [as handle_request] (/home/kingwill101/code/capcom-proj/capcom/node_modules/express/lib/router/layer.js:95:5) at /home/kingwill101/code/capcom-proj/capcom/node_modules/express/lib/router/index.js:284:15 at param (/home/kingwill101/code/capcom-proj/capcom/node_modules/express/lib/router/index.js:365:14) at param (/home/kingwill101/code/capcom-proj/capcom/node_modules/express/lib/router/index.js:376:14) at Function.process_params (/home/kingwill101/code/capcom-proj/capcom/node_modules/express/lib/router/index.js:421:3) http: POST /admin/orders/order_01JCXKEG7XNKSRK8T671FF17AJ ← - (500) - 4.618 ms



### Link to reproduction repo

.
kingwill101 commented 1 day ago

Partially what I wan to solve is moving an order from being a draft order but the previous api no longer exists