{"record":{"id":"9771e110e66619e3","repo":"medusajs/medusa","slug":"exchange-with-id-req-params-id-was-not-found","errorCode":null,"errorMessage":"Exchange with id: ${req.params.id} was not found","messagePattern":"Exchange with id: (.+?) was not found","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/exchanges/[id]/route.ts","lineNumber":21,"sourceCode":"import {\n  AuthenticatedMedusaRequest,\n  MedusaResponse,\n  refetchEntity,\n} from \"@medusajs/framework/http\"\n\nexport const GET = async (\n  req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,\n  res: MedusaResponse<HttpTypes.AdminExchangeResponse>\n) => {\n  const exchange = await refetchEntity({\n    entity: \"order_exchange\",\n    idOrFilter: req.params.id,\n    scope: req.scope,\n    fields: req.queryConfig.fields,\n  })\n\n  if (!exchange) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Exchange with id: ${req.params.id} was not found`\n    )\n  }\n\n  res.status(200).json({ exchange })\n}\n","sourceCodeStart":3,"sourceCodeEnd":29,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/exchanges/[id]/route.ts#L3-L29","documentation":"The GET /admin/exchanges/:id route queries the order module for an exchange by id and throws NOT_FOUND (HTTP 404) if none matches.","triggerScenarios":"GET /admin/exchanges/:id with an invalid or out-of-scope exchange id.","commonSituations":"Deep links to exchanges created in another store/environment; exchanges tied to deleted orders; manually constructed URLs.","solutions":["List exchanges via the order/exchange list endpoints and use returned ids","Handle 404 in exchange detail routing","Verify environment/backend URL"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const { exchanges } = await sdk.admin.order.listExchanges({ id: exchangeId })\nif (!exchanges.length) throw new Error(\"exchange not found\")","typeGuard":"null","tryCatchPattern":"try { await getExchange(id) } catch (e) { if (e.statusCode === 404) navigate(\"/orders\") else throw e }","preventionTips":["Access exchanges via their order's relations","Validate deep-linked ids"],"tags":["admin-api","exchanges","orders","not-found"],"backgroundTag":"http-404-resource-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}