{"record":{"id":"e57778c459bfe432","repo":"medusajs/medusa","slug":"campaign-with-id-req-params-id-not-found","errorCode":null,"errorMessage":"Campaign with id \"${req.params.id}\" not found","messagePattern":"Campaign with id \"(.+?)\" not found","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/campaigns/[id]/route.ts","lineNumber":45,"sourceCode":"      `Campaign with id: ${req.params.id} was not found`\n    )\n  }\n\n  res.status(200).json({ campaign })\n}\n\nexport const POST = async (\n  req: AuthenticatedMedusaRequest<\n    HttpTypes.AdminUpdateCampaign & AdditionalData,\n    HttpTypes.AdminGetCampaignParams\n  >,\n  res: MedusaResponse<HttpTypes.AdminCampaignResponse>\n) => {\n  const existingCampaign = await refetchCampaign(req.params.id, req.scope, [\n    \"id\",\n  ])\n  if (!existingCampaign) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Campaign with id \"${req.params.id}\" not found`\n    )\n  }\n\n  const { additional_data, ...rest } = req.validatedBody\n  const updateCampaigns = updateCampaignsWorkflow(req.scope)\n  const campaignsData = [\n    {\n      id: req.params.id,\n      ...rest,\n    },\n  ]\n\n  await updateCampaigns.run({\n    input: { campaignsData, additional_data },\n  })\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/campaigns/[id]/route.ts#L27-L63","documentation":"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.","triggerScenarios":"POST /admin/campaigns/:id with a body update for a campaign id that does not exist.","commonSituations":"Editing a campaign in the admin after it was deleted elsewhere; race between delete and save; stale form state.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const exists = (await sdk.promotion.listCampaigns({ id })).campaigns.length > 0\nif (!exists) throw new Error(`Campaign ${id} not found; refresh before update`)","typeGuard":"null","tryCatchPattern":"try { await sdk.promotion.updateCampaign(id, payload) } catch (e) { if (e.statusCode === 404) { discardLocalEdits(); reload() } else throw e }","preventionTips":["Refetch entity before showing edit forms","Handle concurrent deletes with a refresh-and-retry UX"],"tags":["admin-api","campaigns","update","not-found"],"backgroundTag":"http-404-update-missing-resource","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}