medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
24.58k stars 2.42k forks source link

Malformed syntax. 2.0.6-preview #8824

Closed HadiSDev closed 2 weeks ago

HadiSDev commented 2 weeks ago

Bug report

Describe the bug

If I go to the edit page of a product I get the following error:

The request could not be understood by the server due to malformed syntax.

image

Stacktrace:


error:   column c12.metadata does not exist
MedusaError: column c12.metadata does not exist
    at dbErrorMapper (/project_name/node_modules/@medusajs/utils/src/dal/mikro-orm/db-error-mapper.ts:60:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AbstractService_.list (/project_name/node_modules/@medusajs/utils/src/modules-sdk/medusa-internal-service.ts:181:14)
    at async ProductModuleService.methodImplementation (/project_name/node_modules/@medusajs/utils/src/modules-sdk/medusa-service.ts:228:26)
    at async RemoteQuery.remoteFetchData (/project_name/node_modules/@medusajs/modules-sdk/src/remote-query.ts:230:20)
    at async RemoteJoiner.fetchData /project_name/node_modules/@medusajs/orchestration/src/joiner/remote-joiner.ts:370:22)
    at async RemoteJoiner.query (/project_name/node_modules/@medusajs/orchestration/src/joiner/remote-joiner.ts:1039:22)
    at async RemoteQuery.query /project_name/node_modules/@medusajs/modules-sdk/src/remote-query.ts:261:12)
    at async query (/project_name/node_modules/@medusajs/modules-sdk/src/medusa-app.ts:421:12)
    at async refetchEntities (/project_name/node_modules/@medusajs/medusa/src/api/utils/refetch-entity.ts:35:10)
    at async refetchEntity (/project_name/node_modules/@medusajs/medusa/src/api/utils/refetch-entity.ts:44:20)
    at async GET (/project_name/node_modules/@medusajs/medusa/src/api/admin/products/[id]/route.ts:19:19)
    at async /project_name/node_modules/@medusajs/utils/src/common/wrap-handler.ts:17:14 {
  type: 'invalid_data',
  code: undefined,
  date: 2024-08-27T19:30:35.836Z
}

System information

Medusa version (including plugins): 2.0.6-preview Node.js version: 21.7.1 Database: postgres Operating system: WSL Browser (if relevant): firefox

Steps to reproduce the behavior

  1. Create a product with 3 variants (standard, premium, luxury)
  2. Set the stock to none (as unlimited). it is a service product
  3. Create an order with that product
  4. Go to product page and then go to the edit page of the newly created product
420coupe commented 2 weeks ago

I am getting a related issue. Except when trying to add the product to cart, getting the following error.

::ffff:127.0.0.1 - - [27/Aug/2024:21:48:02 +0000] "GET /store/regions HTTP/1.1" 200 762 "-" "Next.js Middleware"
::ffff:127.0.0.1 - - [27/Aug/2024:21:48:49 +0000] "GET /store/products?limit=12&offset=0&region_id=reg_01J4WE7JHSS32T9WKDWHPF1YKY&fields=%2Avariants.calculated_price&is_giftcard=false HTTP/1.1" 200 7985 "-" "node"
::ffff:127.0.0.1 - - [27/Aug/2024:21:48:50 +0000] "GET /store/products?id%5B0%5D=prod_01J5WAY0AEQ6S6FS5Z3WG8214A&region_id=reg_01J4WE7JHSS32T9WKDWHPF1YKY&fields=%2Avariants.calculated_price%2C%2Avariants.digital_product HTTP/1.1" 200 4231 "-" "node"
::ffff:127.0.0.1 - - [27/Aug/2024:21:48:50 +0000] "GET /store/products?id%5B0%5D=prod_01J5BXGHGV7SW8FFE5PK7B7WN0&region_id=reg_01J4WE7JHSS32T9WKDWHPF1YKY&fields=%2Avariants.calculated_price%2C%2Avariants.digital_product HTTP/1.1" 200 4134 "-" "node"
::ffff:127.0.0.1 - - [27/Aug/2024:21:48:55 +0000] "POST /store/carts HTTP/1.1" 200 1417 "-" "node"
::ffff:127.0.0.1 - - [27/Aug/2024:21:48:59 +0000] "POST /store/carts/cart_01J6AX09Z23JSBV31VYV2H1SHA/line-items HTTP/1.1" 200 2303 "-" "node"
::ffff:127.0.0.1 - - [27/Aug/2024:21:48:59 +0000] "GET /store/collections?limit=6&offset=0 HTTP/1.1" 200 214 "-" "node"
::ffff:127.0.0.1 - - [27/Aug/2024:21:48:59 +0000] "GET /store/regions HTTP/1.1" 200 762 "-" "node"
error:   select "p0"."id", "p0"."name", "p0"."description", "p0"."handle", "p0"."rank", "p0"."parent_category_id", "p0"."created_at", "p0"."updated_at", "p0"."metadata" from "public"."product_category" as "p0" where "p0"."deleted_at" is null and "p0"."is_active" = true and "p0"."is_internal" = false limit 6 - column p0.metadata does not exist
InvalidFieldNameException: select "p0"."id", "p0"."name", "p0"."description", "p0"."handle", "p0"."rank", "p0"."parent_category_id", "p0"."created_at", "p0"."updated_at", "p0"."metadata" from "public"."product_category" as "p0" where "p0"."deleted_at" is null and "p0"."is_active" = true and "p0"."is_internal" = false limit 6 - column p0.metadata does not exist
    at PostgreSqlExceptionConverter.convertException (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/@mikro-orm/postgresql/PostgreSqlExceptionConverter.js:36:24)
    at PostgreSqlDriver.convertException (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:201:54)
    at /home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:205:24
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SqlEntityManager.find (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/@mikro-orm/core/EntityManager.js:117:25)
    at async Promise.all (index 0)
    at async SqlEntityManager.findAndCount (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/@mikro-orm/core/EntityManager.js:302:35)
    at async ProductCategoryRepository.findAndCount (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/@medusajs/product/dist/repositories/product-category.js:142:44)
    at async ProductCategoryService.listAndCount (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/@medusajs/product/dist/services/product-category.js:79:17)
    at async ProductModuleService.methodImplementation (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/@medusajs/utils/src/modules-sdk/medusa-service.ts:243:35)

previous error: select "p0"."id", "p0"."name", "p0"."description", "p0"."handle", "p0"."rank", "p0"."parent_category_id", "p0"."created_at", "p0"."updated_at", "p0"."metadata" from "public"."product_category" as "p0" where "p0"."deleted_at" is null and "p0"."is_active" = true and "p0"."is_internal" = false limit 6 - column p0.metadata does not exist
    at Parser.parseErrorMessage (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/pg-protocol/src/parser.ts:369:69)
    at Parser.handlePacket (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/pg-protocol/src/parser.ts:188:21)
    at Parser.parse (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/pg-protocol/src/parser.ts:103:30)
    at Socket.<anonymous> (/home/coupe/Documents/medusa/medusa-v2.0.3/node_modules/pg-protocol/src/index.ts:7:48)
    at Socket.emit (node:events:519:28)
    at Socket.emit (node:domain:488:12)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Socket.Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 110,
  severity: 'ERROR',
  code: '42703',
  detail: undefined,
  hint: undefined,
  position: '145',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'parse_relation.c',
  line: '3656',
  routine: 'errorMissingColumn'
}
::ffff:127.0.0.1 - - [27/Aug/2024:21:48:59 +0000] "GET /store/product-categories?limit=6&offset=0 HTTP/1.1" 500 86 "-" "node"

and if i go to admin and try to click on any of the products, the following error occurs.

image

420coupe commented 2 weeks ago

assuming this has to do with this commit. https://github.com/medusajs/medusa/commit/ac18b5d35feae54cc89fa0ee614878054fe996d8

420coupe commented 2 weeks ago

Bug report

Describe the bug

If I go to the edit page of a product I get the following error:

The request could not be understood by the server due to malformed syntax.

image

Stacktrace:

error:   column c12.metadata does not exist
MedusaError: column c12.metadata does not exist
    at dbErrorMapper (/project_name/node_modules/@medusajs/utils/src/dal/mikro-orm/db-error-mapper.ts:60:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AbstractService_.list (/project_name/node_modules/@medusajs/utils/src/modules-sdk/medusa-internal-service.ts:181:14)
    at async ProductModuleService.methodImplementation (/project_name/node_modules/@medusajs/utils/src/modules-sdk/medusa-service.ts:228:26)
    at async RemoteQuery.remoteFetchData (/project_name/node_modules/@medusajs/modules-sdk/src/remote-query.ts:230:20)
    at async RemoteJoiner.fetchData /project_name/node_modules/@medusajs/orchestration/src/joiner/remote-joiner.ts:370:22)
    at async RemoteJoiner.query (/project_name/node_modules/@medusajs/orchestration/src/joiner/remote-joiner.ts:1039:22)
    at async RemoteQuery.query /project_name/node_modules/@medusajs/modules-sdk/src/remote-query.ts:261:12)
    at async query (/project_name/node_modules/@medusajs/modules-sdk/src/medusa-app.ts:421:12)
    at async refetchEntities (/project_name/node_modules/@medusajs/medusa/src/api/utils/refetch-entity.ts:35:10)
    at async refetchEntity (/project_name/node_modules/@medusajs/medusa/src/api/utils/refetch-entity.ts:44:20)
    at async GET (/project_name/node_modules/@medusajs/medusa/src/api/admin/products/[id]/route.ts:19:19)
    at async /project_name/node_modules/@medusajs/utils/src/common/wrap-handler.ts:17:14 {
  type: 'invalid_data',
  code: undefined,
  date: 2024-08-27T19:30:35.836Z
}

System information

Medusa version (including plugins): 2.0.6-preview Node.js version: 21.7.1 Database: postgres Operating system: WSL Browser (if relevant): firefox

Steps to reproduce the behavior

  1. Create a product with 3 variants (standard, premium, luxury)
  2. Set the stock to none (as unlimited). it is a service product
  3. Create an order with that product
  4. Go to product page and then go to the edit page of the newly created product

found the issue. run the following commands to update your db.

npx medusa migrations run npx medusa links sync

olivermrbl commented 2 weeks ago

Yes, this is due to an added migration. Please run the scripts as advised above.