nopSolutions/nopCommerce · warning · Exception

Enter shipped date

Error message

Enter shipped date

What it means

Thrown in the OrderController shipment 'set as shipped' action when model.ShippedDateUtc has no value (null DateTime?). The action requires an explicit shipped date before updating the shipment record. Uses the base Exception type (not NopException); caught and surfaced via ErrorNotificationAsync, then redirects back to shipment details.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/OrderController.cs:2225

    [HttpPost, ActionName("ShipmentDetails")]
    [FormValueRequired("saveshippeddate")]
    [CheckPermission(StandardPermission.Orders.SHIPMENTS_CREATE_EDIT_DELETE)]
    public virtual async Task<IActionResult> EditShippedDate(ShipmentModel model)
    {
        //try to get a shipment with the specified id
        var shipment = await _shipmentService.GetShipmentByIdAsync(model.Id);
        if (shipment == null)
            return RedirectToAction("List");

        //a vendor should have access only to his products
        if (await _workContext.GetCurrentVendorAsync() != null && !await HasAccessToShipmentAsync(shipment))
            return RedirectToAction("List");

        try
        {
            if (!model.ShippedDateUtc.HasValue)
                throw new Exception("Enter shipped date");

            shipment.ShippedDateUtc = model.ShippedDateUtc;
            await _shipmentService.UpdateShipmentAsync(shipment);
            return RedirectToAction("ShipmentDetails", new { id = shipment.Id });
        }
        catch (Exception exc)
        {
            //error
            await _notificationService.ErrorNotificationAsync(exc);
            return RedirectToAction("ShipmentDetails", new { id = shipment.Id });
        }
    }

    [HttpPost, ActionName("ShipmentDetails")]
    [FormValueRequired("setasreadyforpickup")]
    [CheckPermission(StandardPermission.Orders.SHIPMENTS_CREATE_EDIT_DELETE)]
    public virtual async Task<IActionResult> SetAsReadyForPickup(int id)
    {

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Select a shipped date in the date picker before submitting.
  2. Ensure the ShippedDateUtc field is included in the POST payload and parses server-side.
  3. Add a client-side 'required' validator on the shipped date input.
  4. If the date should default to now, populate ShippedDateUtc = DateTime.UtcNow when the field is empty rather than throwing.

Example fix

// before
if (!model.ShippedDateUtc.HasValue)
    throw new Exception("Enter shipped date");
shipment.ShippedDateUtc = model.ShippedDateUtc;

// after — default to now when omitted
shipment.ShippedDateUtc = model.ShippedDateUtc ?? DateTime.UtcNow;
await _shipmentService.UpdateShipmentAsync(shipment);
Defensive patterns

Strategy: validation

Validate before calling

// Before marking shipped: ensure a date, defaulting to now if omitted
if (!model.ShippedDateUtc.HasValue)
    model.ShippedDateUtc = DateTime.UtcNow;
shipment.ShippedDateUtc = model.ShippedDateUtc;

Type guard

bool HasShippedDate(ShipmentModel m) => m.ShippedDateUtc.HasValue;

Try / catch

// The action's try/catch shows the exception via ErrorNotificationAsync; pre-validate the date client-side.

Prevention

When it happens

Trigger: POST to mark a shipment as shipped with ShippedDateUtc omitted or null — e.g. the date picker was left empty or the field was not posted.

Common situations: A form customization that removed or hid the shipped-date picker; client-side required validation disabled; an API/integration call to the endpoint that omitted the date field; browser date-picker returning empty due to format mismatch.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/ed574ce5e523ac2b. Report an issue: GitHub.