medusajs/medusa · error · MedusaError
Campaign with id "${req.params.id}" not found
Error message
Campaign with id "${req.params.id}" not found What it means
The POST (update) /admin/campaigns/:id route first refetches the campaign by id to guard updates; a missing record throws NOT_FOUND (HTTP 404) before any update logic runs.
Source
Thrown at packages/medusa/src/api/admin/campaigns/[id]/route.ts:45
`Campaign with id: ${req.params.id} was not found`
)
}
res.status(200).json({ campaign })
}
export const POST = async (
req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateCampaign & AdditionalData,
HttpTypes.AdminGetCampaignParams
>,
res: MedusaResponse<HttpTypes.AdminCampaignResponse>
) => {
const existingCampaign = await refetchCampaign(req.params.id, req.scope, [
"id",
])
if (!existingCampaign) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Campaign with id "${req.params.id}" not found`
)
}
const { additional_data, ...rest } = req.validatedBody
const updateCampaigns = updateCampaignsWorkflow(req.scope)
const campaignsData = [
{
id: req.params.id,
...rest,
},
]
await updateCampaigns.run({
input: { campaignsData, additional_data },
})
View on GitHub (pinned to 5e06e544a2)
Solutions
- Confirm the campaign exists (GET /admin/campaigns/:id) before submitting the update
- Refresh the campaign list/form after deletion events
- Treat 404 on update as a signal to discard local edits and re-fetch
Defensive patterns
Strategy: validation
Validate before calling
const exists = (await sdk.promotion.listCampaigns({ id })).campaigns.length > 0
if (!exists) throw new Error(`Campaign ${id} not found; refresh before update`) Type guard
null
Try / catch
try { await sdk.promotion.updateCampaign(id, payload) } catch (e) { if (e.statusCode === 404) { discardLocalEdits(); reload() } else throw e } Prevention
- Refetch entity before showing edit forms
- Handle concurrent deletes with a refresh-and-retry UX
When it happens
Trigger: POST /admin/campaigns/:id with a body update for a campaign id that does not exist.
Common situations: Editing a campaign in the admin after it was deleted elsewhere; race between delete and save; stale form state.
Related errors
- Campaign with id: ${req.params.id} was not found
- Customer group with id "${req.params.id}" not found
- Customer with id "${req.params.id}" not found
- Claim with id: ${req.params.id} was not found
- Collection with id "${req.params.id}" not found
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/e57778c459bfe432.
Report an issue: GitHub.