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

Error: Cannot read properties of undefined (reading 'items') when creating a return via Store API #9332

Open
Dev-Abdullah-H opened this issue Sep 26, 2024 · 0 comments

Comments

@Dev-Abdullah-H
Copy link

Dev-Abdullah-H commented Sep 26, 2024

Bug report

Describe the bug

When attempting to create a return using the store API (http://localhost:9000/store/return), the request results in an unknown error. The response received is {"code": "unknown_error", "type": "unknown_error", "message": "An unknown error occurred."}. The Medusa admin terminal logs an error indicating that it cannot read properties of undefined, specifically items.

System information

Medusa version (including plugins): preview / v2.0.10
Node.js version: 20.17.0
Database: Postgres 16.4

Steps to reproduce the behavior

  1. Make a POST request to http://localhost:9000/store/return
curl --location 'http://localhost:9000/store/return' \
--header 'Content-Type: application/json' \
--header 'x-publishable-api-key: pk_10150e6c0669af1e359b2**********************' \
--header 'Cookie: connect.sid=s%3AnUQqUNMH7yU3zkJlS9JPIZ7m_r2ihh2z.WZh9aa****************' \
--data '{
    "order_id": "order_01J8Q1Y7HE2VF55E7NQ9PRPPP9",
    "items" : [{
        "id": "ordli_01J8Q1Y7HFZE1WQ8MEE4K7CERV",
        "quantity": 1,
        "reason_id": "rr_01J8B1A06M6KJ0GBGMY11XBZDA"
    }],
    "return_shipping": {
        "option_id": "so_01J6RTYHDNVRZ7EYMH9KEKCMJZ"
    }
}'
  1. Observe the response:
{
    "code": "unknown_error",
    "type": "unknown_error",
    "message": "An unknown error occurred."
}
  1. Check the Medusa admin terminal for errors:
{
  message: "Cannot read properties of undefined (reading 'items')",
  name: 'TypeError',
  stack: "TypeError: Cannot read properties of undefined (reading 'items')\n" +
    '    at Object.<anonymous> (E:\\Work\\medusa-poc-0824\\medusa-admin\\node_modules\\@medusajs\\core-flows\\dist\\order\\workflows\\return\\create-complete-return.js:119:16)\n' +
    '    at Object.invoke (E:\\Work\\medusa-poc-0824\\medusa-admin\\node_modules\\@medusajs\\workflows-sdk\\src\\utils\\composer\\helpers\\create-step-handler.ts:58:67)\n' +       
    '    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
    '    at async DistributedTransaction.handler (E:\\Work\\medusa-poc-0824\\medusa-admin\\node_modules\\@medusajs\\orchestration\\src\\workflow\\workflow-manager.ts:214:16)\n' +  
    '    at async stepHandler (E:\\Work\\medusa-poc-0824\\medusa-admin\\node_modules\\@medusajs\\orchestration\\src\\transaction\\transaction-orchestrator.ts:788:20)\n' +
    '    at async Promise.allSettled (index 0)\n' +
    '    at async promiseAll (E:\\Work\\medusa-poc-0824\\medusa-admin\\node_modules\\@medusajs\\utils\\src\\common\\promise-all.ts:23:18)\n' +
    '    at async TransactionOrchestrator.executeNext (E:\\Work\\medusa-poc-0824\\medusa-admin\\node_modules\\@medusajs\\orchestration\\src\\transaction\\transaction-orchestrator.ts:920:7)\n' +
    '    at async executeNext (E:\\Work\\medusa-poc-0824\\medusa-admin\\node_modules\\@medusajs\\orchestration\\src\\transaction\\transaction-orchestrator.ts:968:14)\n' +
    '    at async TransactionOrchestrator.resume (E:\\Work\\medusa-poc-0824\\medusa-admin\\node_modules\\@medusajs\\orchestration\\src\\transaction\\transaction-orchestrator.ts:983:5)'     
}

Expected behavior

I expect the return creation process to complete successfully and return a confirmation response.

Screenshots

Error
Error-2

Additional context

I attempted to console log the input in create-complete-return.js at line 118, and the result is undefined, which indicates that the data structure being passed may not be correctly formatted or that the required data is not being retrieved properly.

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

1 participant