medusajs/medusa · error · MedusaError

Collection with id "${req.params.id}" not found

Error message

Collection with id "${req.params.id}" not found

What it means

The POST (update) /admin/collections/:id route refetches the product collection before updating; if the collection id does not exist it throws NOT_FOUND (HTTP 404).

Source

Thrown at packages/medusa/src/api/admin/collections/[id]/route.ts:39

    req.scope,
    req.queryConfig.fields
  )

  res.status(200).json({ collection })
}

export const POST = async (
  req: AuthenticatedMedusaRequest<
    AdminUpdateCollectionType & AdditionalData,
    HttpTypes.AdminCollectionParams
  >,
  res: MedusaResponse<HttpTypes.AdminCollectionResponse>
) => {
  const existingCollection = await refetchCollection(req.params.id, req.scope, [
    "id",
  ])
  if (!existingCollection) {
    throw new MedusaError(
      MedusaError.Types.NOT_FOUND,
      `Collection with id "${req.params.id}" not found`
    )
  }

  const { additional_data, ...rest } = req.validatedBody

  await updateCollectionsWorkflow(req.scope).run({
    input: {
      selector: { id: req.params.id },
      update: rest,
      additional_data,
    },
  })

  const collection = await refetchCollection(
    req.params.id,
    req.scope,

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Verify via GET /admin/collections/:id before updating
  2. Re-list collections to refresh ids after deletions
  3. Handle 404 by resetting the edit form and notifying the user
Defensive patterns

Strategy: validation

Validate before calling

const exists = (await sdk.admin.product.listCollections({ id })).collections.length > 0
if (!exists) throw new Error("collection deleted")

Type guard

null

Try / catch

try { await sdk.admin.product.updateCollection(id, payload) } catch (e) { if (e.statusCode === 404) { refreshCollections(); notify("Collection no longer exists") } else throw e }

Prevention

When it happens

Trigger: POST /admin/collections/:id updating a product collection whose id does not exist or was deleted.

Common situations: Collection deleted while the edit drawer was open in the dashboard; batch import scripts referencing stale collection ids.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/d58d2b11a2351651. Report an issue: GitHub.