Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Invalid type error on product image upload #10889

Closed
RubenDobbels opened this issue Jan 9, 2025 · 2 comments
Closed

[Bug]: Invalid type error on product image upload #10889

RubenDobbels opened this issue Jan 9, 2025 · 2 comments

Comments

@RubenDobbels
Copy link

Package.json file

{
  "name": "likha-manilenia-medusa-backend",
  "version": "0.0.2",
  "description": "Based on the medusa starter project.",
  "author": "Ruben Dobbels",
  "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": {
    "@lexical/react": "^0.19.0",
    "@medusajs/admin-sdk": "^2.0.0",
    "@medusajs/cli": "^2.0.0",
    "@medusajs/framework": "^2.0.0",
    "@medusajs/medusa": "^2.0.0",
    "@mikro-orm/core": "5.9.7",
    "@mikro-orm/knex": "5.9.7",
    "@mikro-orm/migrations": "5.9.7",
    "@mikro-orm/postgresql": "5.9.7",
    "@tiptap/extension-bold": "^2.9.1",
    "@tiptap/extension-bullet-list": "^2.9.1",
    "@tiptap/extension-document": "^2.9.1",
    "@tiptap/extension-heading": "^2.9.1",
    "@tiptap/extension-history": "^2.9.1",
    "@tiptap/extension-italic": "^2.9.1",
    "@tiptap/extension-link": "^2.9.1",
    "@tiptap/extension-list-item": "^2.9.1",
    "@tiptap/extension-ordered-list": "^2.9.1",
    "@tiptap/extension-paragraph": "^2.9.1",
    "@tiptap/extension-strike": "^2.9.1",
    "@tiptap/extension-text": "^2.9.1",
    "@tiptap/extension-text-align": "^2.9.1",
    "@tiptap/extension-underline": "^2.9.1",
    "@tiptap/react": "^2.9.1",
    "awilix": "^8.0.1",
    "express-handlebars": "^8.0.1",
    "handlebars": "^4.7.8",
    "nodemailer": "^6.9.16",
    "pg": "^8.13.0",
    "react-icons": "^5.3.0"
  },
  "devDependencies": {
    "@medusajs/test-utils": "^2.0.0",
    "@mikro-orm/cli": "5.9.7",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@tailwindcss/typography": "^0.5.15",
    "@types/jest": "^29.5.13",
    "@types/node": "^20.0.0",
    "@types/nodemailer": "^6.4.16",
    "@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

v23.6

Database and its version

PostgreSQL 17.2

Operating system name and version

Docker Version 27.3.1

Browser name

Chrome 131.0.6778.205

What happended?

When trying to upload a product image file in production I get "Failed to upload the added media. Please try again."
Running the container locally it seems to be able to upload fine.
I'm using DigitalOcean Spaces configured as in the docs.
image

First image uploaded fine when running the server locally.
Second image is trying to upload in prod.
Access keys being used between running locally and prod is the same.

image

Expected behavior

I can upload product image files

Actual behavior

I'm getting this error:
error: [ { "code": "invalid_type", "expected": "string", "received": "undefined", "path": [ "images", 1, "url" ], "message": "Required" } ] ZodError: [ { "code": "invalid_type", "expected": "string", "received": "undefined", "path": [ "images", 1, "url" ], "message": "Required" } ] at Object.get error [as error] (/home/node/app/node_modules/@medusajs/medusa/node_modules/zod/lib/types.js:43:31) at ZodObject.parseAsync (/home/node/app/node_modules/@medusajs/medusa/node_modules/zod/lib/types.js:166:22) at processTicksAndRejections (node:internal/process/task_queues:105:5) at async zodValidator (/home/node/app/node_modules/@medusajs/framework/src/zod/zod-helpers.ts:123:12) at async validateBody (/home/node/app/node_modules/@medusajs/framework/src/http/utils/validate-body.ts:30:27) { issues: [ { code: 'invalid_type', expected: 'string', received: 'undefined', path: [Array], message: 'Required' } ], addIssue: [Function (anonymous)], addIssues: [Function (anonymous)], errors: [ { code: 'invalid_type', expected: 'string', received: 'undefined', path: [Array], message: 'Required' } ] } http: POST /admin/products/prod_01JBKWZYVPSABP5XQMW824E6E7 ← https://XXX/app/products/prod_01JBKWZYVPSABP5XQMW824E6E7/media?view=edit (500) - 5.748 ms

Link to reproduction repo

how to reproduce without API keys?

@sradevski
Copy link
Member

I think the error is for a later call (updating the product data), meaning the upload of the file itself failed. Do you have logs from the backend? I imagine it could be misconfiguration of the provider or something along those lines, preventing you from successfully uploading the file.

@sradevski
Copy link
Member

No reply, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants