{"record":{"id":"ba853c4f316318b4","repo":"medusajs/medusa","slug":"the-following-shipping-options-do-not-exist-arr","errorCode":null,"errorMessage":"The following shipping options do not exist: ${Array.from(missingShippingOptionIds).join(\", \")}","messagePattern":"The following shipping options do not exist: (.+?)","errorType":"exception","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/modules/fulfillment/src/services/fulfillment-module-service.ts","lineNumber":2108,"sourceCode":"        MedusaError.Types.INVALID_DATA,\n        `Fulfillment with id ${fulfillment.id} already delivered`\n      )\n    }\n\n    return true\n  }\n\n  protected static validateMissingShippingOptions_(\n    shippingOptions: InferEntityType<typeof ShippingOption>[],\n    shippingOptionsData: UpdateShippingOptionsInput[]\n  ) {\n    const missingShippingOptionIds = arrayDifference(\n      shippingOptionsData.map((s) => s.id),\n      shippingOptions.map((s) => s.id)\n    )\n\n    if (missingShippingOptionIds.length) {\n      throw new MedusaError(\n        MedusaError.Types.NOT_FOUND,\n        `The following shipping options do not exist: ${Array.from(\n          missingShippingOptionIds\n        ).join(\", \")}`\n      )\n    }\n  }\n\n  protected static validateMissingShippingOptionRules(\n    shippingOption: InferEntityType<typeof ShippingOption>,\n    shippingOptionUpdateData: FulfillmentTypes.UpdateShippingOptionDTO\n  ) {\n    if (!shippingOptionUpdateData.rules) {\n      return\n    }\n\n    const existingRules = shippingOption.rules\n","sourceCodeStart":2090,"sourceCodeEnd":2126,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/fulfillment/src/services/fulfillment-module-service.ts#L2090-L2126","documentation":"Thrown by the Fulfillment module when updating shipping options that reference other shipping options (e.g. via `shipping_option_id` on rules or type data) where some of the referenced options do not exist in the database. The module diffs requested IDs against actually loaded options and reports the missing ones. It is a NOT_FOUND MedusaError.","triggerScenarios":"Calling fulfillmentModuleService.updateShippingOptions with entries whose rules or attached data reference shipping option IDs that were deleted or never created (e.g. after data migrations or copying configs between environments).","commonSituations":"Seed scripts referencing stale shipping option IDs, running updates after options were soft-deleted, or environment drift between staging and production data.","solutions":["Verify the listed shipping option IDs exist: listShippingOptions({ id: [...] })","Re-create or restore the missing shipping options before re-running the update","Remove references to the deleted options from your update payload"],"exampleFix":"// before\nawait fulfillmentService.updateShippingOptions([\n  { id: so.id, rules: [{ operator: 'eq', attribute: 'x', value: 'y', shipping_option_id: 'so_123' }] }, // so_123 deleted\n])\n// after\nconst existing = await fulfillmentService.listShippingOptions({ id: ['so_123'] })\nif (!existing.length) {\n  // recreate or drop the reference\n}","handlingStrategy":"validation","validationCode":"const existing = await fulfillmentService.listShippingOptions({ id: referencedIds })\nconst existingIds = new Set(existing.map((o) => o.id))\nconst missing = referencedIds.filter((id) => !existingIds.has(id))\nif (missing.length) throw new Error(`Missing shipping options: ${missing.join(', ')}`)","typeGuard":"const isValidShippingOptionRef = (o: { id?: string }, ids: Set<string>): boolean => !!o.id && ids.has(o.id)","tryCatchPattern":"catch (e) { if (e instanceof MedusaError && e.type === MedusaError.Types.NOT_FOUND) { /* re-sync local option list */ } throw e }","preventionTips":["Re-fetch shipping option IDs before updates instead of caching them","Validate referenced IDs against listShippingOptions before mutating"],"tags":["fulfillment","shipping-options","not-found","validation"],"backgroundTag":"referenced-entity-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}