{"record":{"id":"5ecd25bccd4bbec8","repo":"nopSolutions/nopCommerce","slug":"shipping-address-is-not-available","errorCode":null,"errorMessage":"Shipping address is not available","messagePattern":"Shipping address is not available","errorType":"validation","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/Orders/OrderProcessingService.cs","lineNumber":663,"sourceCode":"        details.CheckoutAttributeDescription = details.InitialOrder.CheckoutAttributeDescription;\r\n\r\n        //tax display type\r\n        details.CustomerTaxDisplayType = details.InitialOrder.CustomerTaxDisplayType;\r\n\r\n        //sub total\r\n        details.OrderSubTotalInclTax = details.InitialOrder.OrderSubtotalInclTax;\r\n        details.OrderSubTotalExclTax = details.InitialOrder.OrderSubtotalExclTax;\r\n        details.OrderSubTotalDiscountExclTax = details.InitialOrder.OrderSubTotalDiscountExclTax;\r\n        details.OrderSubTotalDiscountInclTax = details.InitialOrder.OrderSubTotalDiscountInclTax;\r\n\r\n        //shipping info\r\n        if (details.InitialOrder.ShippingStatus != ShippingStatus.ShippingNotRequired)\r\n        {\r\n            details.PickupInStore = details.InitialOrder.PickupInStore;\r\n            if (!details.PickupInStore)\r\n            {\r\n                if (!details.InitialOrder.ShippingAddressId.HasValue || await _addressService.GetAddressByIdAsync(details.InitialOrder.ShippingAddressId.Value) is not Address shippingAddress)\r\n                    throw new NopException(\"Shipping address is not available\");\r\n\r\n                //clone shipping address\r\n                details.ShippingAddress = _addressService.CloneAddress(shippingAddress);\r\n                if (await _countryService.GetCountryByAddressAsync(details.ShippingAddress) is Country shippingCountry && !shippingCountry.AllowsShipping)\r\n                    throw new NopException($\"Country '{shippingCountry.Name}' is not allowed for shipping\");\r\n            }\r\n            else if (details.InitialOrder.PickupAddressId.HasValue && await _addressService.GetAddressByIdAsync(details.InitialOrder.PickupAddressId.Value) is Address pickupAddress)\r\n                details.PickupAddress = _addressService.CloneAddress(pickupAddress);\r\n\r\n            details.ShippingMethodName = details.InitialOrder.ShippingMethod;\r\n            details.ShippingRateComputationMethodSystemName = details.InitialOrder.ShippingRateComputationMethodSystemName;\r\n            details.ShippingStatus = ShippingStatus.NotYetShipped;\r\n        }\r\n        else\r\n            details.ShippingStatus = ShippingStatus.ShippingNotRequired;\r\n\r\n        //shipping total\r\n        details.OrderShippingTotalInclTax = details.InitialOrder.OrderShippingInclTax;\r","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/Orders/OrderProcessingService.cs#L645-L681","documentation":"Thrown during the reorder/recurring-payment pipeline when the InitialOrder requires shipping (ShippingStatus != ShippingNotRequired) and is not pickup-in-store, but the ShippingAddressId is null or the referenced address record does not exist in the database. This is a data-integrity check ensuring the reorder has a deliverable destination.","triggerScenarios":"The InitialOrder's shipping address record was deleted from the Address table, the ShippingAddressId is null (corrupted or never set), or an async resolution returned null because the address was soft-deleted by a cleanup process. This is specific to the reorder path which re-reads the address by ID rather than from the customer.","commonSituations":"Database cleanup or GDPR-compliance scripts that deleted address records without nullifying order references. Data migration that failed to carry over shipping address records. Address records deleted via direct SQL or a custom plugin that bypassed referential integrity checks. An order created by a now-purged guest session.","solutions":["Query the database for the InitialOrder's ShippingAddressId and verify the Address record exists.","If the address was deleted, restore it from backup or recreate it from the order's stored address snapshot.","Run a referential integrity check: find orders whose ShippingAddressId has no matching Address record.","If the order no longer needs shipping (e.g. digital goods re-fulfillment), set ShippingStatus to ShippingNotRequired.","Prevent address deletion by adding a foreign key constraint or a pre-delete check for order references."],"exampleFix":"// before: order.ShippingAddressId = 1234; Address 1234 deleted from DB\n// after:\nvar address = await _addressService.InsertAddressAsync(restoredAddress);\norder.ShippingAddressId = address.Id;\nawait _orderService.UpdateOrderAsync(order);","handlingStrategy":"validation","validationCode":"// Before reorder, validate the initial order's shipping address exists\nif (initialOrder.ShippingStatus != ShippingStatus.ShippingNotRequired\n    && !initialOrder.PickupInStore)\n{\n    if (!initialOrder.ShippingAddressId.HasValue)\n    {\n        _logger.LogError(\"Order {OrderId} has no shipping address ID\", initialOrder.Id);\n        return;\n    }\n    var addr = await _addressService.GetAddressByIdAsync(initialOrder.ShippingAddressId.Value);\n    if (addr == null)\n    {\n        _logger.LogError(\"Order {OrderId} references deleted shipping address {AddressId}\",\n            initialOrder.Id, initialOrder.ShippingAddressId);\n        return;\n    }\n}","typeGuard":"async Task<bool> ReorderShippingAddressValidAsync(\n    IAddressService addrSvc, Order o) =>\n    o.ShippingStatus == ShippingStatus.ShippingNotRequired\n    || o.PickupInStore\n    || (o.ShippingAddressId.HasValue\n        && await addrSvc.GetAddressByIdAsync(o.ShippingAddressId.Value) != null);","tryCatchPattern":"try\n{\n    var result = await _orderProcessingService.ReOrderAsync(initialOrder, processPaymentRequest);\n}\ncatch (NopException ex) when (ex.Message == \"Shipping address is not available\")\n{\n    _logger.LogError(ex, \"Reorder failed: shipping address missing for order {OrderId}\", initialOrder.Id);\n    // restore address from backup or cancel the reorder\n}","preventionTips":["Never hard-delete address records without checking for order references.","Add a foreign key constraint on Order.ShippingAddressId to prevent orphaned references.","Run periodic referential integrity audits: find orders whose ShippingAddressId has no matching Address.","Before running reorder/recurring jobs, validate source orders have existing shipping address records.","Implement soft-delete for addresses instead of hard-delete to preserve order history."],"tags":["nopcommerce","shipping-address","reorder","data-integrity","referential-integrity","order-processing"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}