Skip to content

[Bug]: Invalid field error when updating shipping_address via cart update API #12966

@leosin

Description

@leosin

Package.json file

{
  "name": "nuxt-app",
  "type": "module",
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev --port 50526",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
    "lint": "eslint ."
  },
  "dependencies": {
    "@deeptimes/fapro": "^0.6.7",
    "@fontsource-variable/roboto": "^5.2.6",
    "@fontsource/roboto": "^5.2.6",
    "@medusajs/js-sdk": "^2.8.6",
    "@medusajs/types": "^2.8.6",
    "@nuxt/fonts": "0.11.4",
    "@nuxt/icon": "1.13.0",
    "@nuxt/image": "^1.10.0",
    "@nuxt/kit": "^3.17.6",
    "@nuxt/scripts": "0.11.7",
    "@nuxtjs/device": "^3.2.4",
    "@nuxtjs/medusa": "1.1.0",
    "@primevue/forms": "^4.3.6",
    "@tailwindcss/vite": "^4.1.11",
    "@unhead/vue": "^2.0.12",
    "@vee-validate/nuxt": "^4.15.1",
    "@vee-validate/zod": "^4.15.1",
    "axios": "^1.10.0",
    "canvas-confetti": "^1.9.3",
    "floating-vue": "^5.2.2",
    "nuxt": "^3.17.6",
    "nuxt-swiper": "2.0.1",
    "nuxt-zod-i18n": "^1.12.0",
    "pinia-plugin-persistedstate": "^4.4.1",
    "primevue": "^4.3.6",
    "swiper": "^11.2.10",
    "tailwind-merge": "^3.3.1",
    "tailwindcss": "^4.1.11",
    "tailwindcss-primeui": "^0.6.1",
    "vue": "^3.5.17",
    "vue-router": "^4.5.1",
    "zod": "^3.25.74"
  },
  "devDependencies": {
    "@antfu/eslint-config": "^4.16.2",
    "@iconify-json/flag": "^1.2.6",
    "@iconify-json/lucide": "^1.2.55",
    "@nuxtjs/color-mode": "^3.5.2",
    "@nuxtjs/i18n": "^9.5.6",
    "@pinia/nuxt": "^0.11.1",
    "@primevue/nuxt-module": "^4.3.6",
    "@tailwindcss/typography": "^0.5.16",
    "@types/canvas-confetti": "^1.9.0",
    "@types/node": "^22.16.0",
    "@vueuse/core": "^13.5.0",
    "@vueuse/nuxt": "^13.5.0",
    "eslint": "^9.30.1",
    "pinia": "^3.0.3",
    "sass-embedded": "^1.89.2",
    "tsx": "^4.20.3",
    "typescript": "^5.8.3"
  }
}

Node.js version

v21.00

Database and its version

PostgreSQL 17

Operating system name and version

macos

Browser name

chrome

What happended?

I'm encountering an issue when trying to update the shipping_address through the cart update API endpoint /store/carts/{id}. According to the documentation, when updating an address, the id field should be included, while omitting the id creates a new address. However, when I include the id in my request payload, I receive an "Invalid request" error.

Image

Due to this issue, I'm forced to omit the id field from the request, which results in creating a new address record every time I update the cart instead of updating the existing one. This leads to unnecessary address duplication in the system.

Expected behavior

The cart's shipping address should be updated successfully when the id field is provided, as stated in the documentation.

Actual behavior

The API returns an error message:

message: "Invalid request: Unrecognized fields: 'id'"

I'm unsure if this is a bug in the API implementation or if I'm using the endpoint incorrectly. Could you please clarify the correct way to update shipping addresses via the cart update API?

Link to reproduction repo

https://docs.medusajs.com/api/store#carts_postcartsid

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions