#Getting an `AwilixResolutionError` when resolving `ContainerRegistrationKeys.QUERY` in a step

8 messages · Page 1 of 1 (latest)

raw birch
#

We get an AwilixResolutionError when resolving ContainerRegistrationKeys.QUERY in a step.

error:   Could not resolve 'query'.

Resolution path: query
{
  message: "Could not resolve 'query'.\n\nResolution path: query",
  name: 'AwilixResolutionError',
  stack: "AwilixResolutionError: Could not resolve 'query'.\n" +
    '\n' +
    'Resolution path: query\n' +
    '    ...'
}

This is very strange because it only occurs when making a direct API call using RapidAPI Client (a tool similar to Postman). But when we use the admin dashboard UI to initiate a request with the interface and the step is executed, it works as expected.

Medusa v2.1.1

serene sluice
#

Can you export the request in your tool and compare it with the request being sent in the admin dashboard using chrome network tab?

raw birch
serene sluice
#

There should be an extra cookie or header or something which would be causing the difference in behavior. You'll be able to find the issue if you find out what's different in the requests

raw birch
#

Here is the fetch version of RapidAPI Client.

const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY3Rvcl9pZCI6InVzZXJfMDFKQzNFU1I4NjQwVlJNUjFYWVlOMEMzWFciLCJhY3Rvcl90eXBlIjoidXNlciIsImF1dGhfaWRlbnRpdHlfaWQiOiJhdXRoaWRfMDFKQzNFU1JBUDhWMFFXRUVWUUFQRzY5REYiLCJhcHBfbWV0YWRhdGEiOnsidXNlcl9pZCI6InVzZXJfMDFKQzNFU1I4NjQwVlJNUjFYWVlOMEMzWFcifSwiaWF0IjoxNzMzOTgxODU0LCJleHAiOjE3MzQwNjgyNTR9.FbxqPo6wuMTTRhShcoarGaeI2DuKRL6P2ET8hDVY5tU'
  },
  body: new URLSearchParams({})
};

fetch('http://localhost:9000/admin/storrum/orders', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Here is the fetch version when using the dashboard.

fetch("http://localhost:9000/admin/storrum/assign-role", {
  "headers": {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "cache-control": "no-cache",
    "content-type": "application/json",
    "pragma": "no-cache",
    "sec-ch-ua": "\"Chromium\";v=\"125\", \"Not.A/Brand\";v=\"24\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Linux\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-site"
  },
  "referrer": "http://localhost:5173/",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": "{\"roleId\":\"01JC3KAK2WKS8VADE6Z0JR2JDS\",\"userId\":\"user_01JEWX2DX2CHM2TXWSZHS70TBQ\"}",
  "method": "POST",
  "mode": "cors",
  "credentials": "include"
});
raw birch
#

We were missing the scope when executing the workflow.

await myWorkflow() // leading to the error

Problem fixed when passing the scope as we should.

await myWorkflow(req.scope) // fixes the error
molten sable
#

Thanks you @raw birch for always sharing your solution and marking the thread as solved ! 🔥

heady swan