medusajs/medusa · error · MedusaError
Exchange with id: ${req.params.id} was not found
Error message
Exchange with id: ${req.params.id} was not found What it means
The GET /admin/exchanges/:id route queries the order module for an exchange by id and throws NOT_FOUND (HTTP 404) if none matches.
Source
Thrown at packages/medusa/src/api/admin/exchanges/[id]/route.ts:21
import {
AuthenticatedMedusaRequest,
MedusaResponse,
refetchEntity,
} from "@medusajs/framework/http"
export const GET = async (
req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminExchangeResponse>
) => {
const exchange = await refetchEntity({
entity: "order_exchange",
idOrFilter: req.params.id,
scope: req.scope,
fields: req.queryConfig.fields,
})
if (!exchange) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Exchange with id: ${req.params.id} was not found`
)
}
res.status(200).json({ exchange })
}
View on GitHub (pinned to 5e06e544a2)
Solutions
- List exchanges via the order/exchange list endpoints and use returned ids
- Handle 404 in exchange detail routing
- Verify environment/backend URL
Defensive patterns
Strategy: try-catch
Validate before calling
const { exchanges } = await sdk.admin.order.listExchanges({ id: exchangeId })
if (!exchanges.length) throw new Error("exchange not found") Type guard
null
Try / catch
try { await getExchange(id) } catch (e) { if (e.statusCode === 404) navigate("/orders") else throw e } Prevention
- Access exchanges via their order's relations
- Validate deep-linked ids
When it happens
Trigger: GET /admin/exchanges/:id with an invalid or out-of-scope exchange id.
Common situations: Deep links to exchanges created in another store/environment; exchanges tied to deleted orders; manually constructed URLs.
Related errors
- Claim with id: ${req.params.id} was not found
- Campaign with id: ${req.params.id} was not found
- Campaign with id "${req.params.id}" not found
- Currency with code: ${req.params.code} was not found
- Customer group with id: ${req.params.id} not found
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/9771e110e66619e3.
Report an issue: GitHub.