nopSolutions/nopCommerce · error · ArgumentException

No vendor found with the specified id

Error message

No vendor found with the specified id

What it means

Thrown by VendorController.VendorNotesSelect when IVendorService.GetVendorByIdAsync(searchModel.VendorId) returns null. This AJAX endpoint (behind VENDORS_VIEW permission) loads the notes sub-grid for a vendor; a missing vendor record yields ArgumentException before the note-list model is prepared.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/VendorController.cs:500

        await _customerActivityService.InsertActivityAsync("DeleteVendor",
            string.Format(await _localizationService.GetResourceAsync("ActivityLog.DeleteVendor"), vendor.Id), vendor);

        _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Vendors.Deleted"));

        return RedirectToAction("List");
    }

    #endregion

    #region Vendor notes

    [HttpPost]
    [CheckPermission(StandardPermission.Customers.VENDORS_VIEW)]
    public virtual async Task<IActionResult> VendorNotesSelect(VendorNoteSearchModel searchModel)
    {
        //try to get a vendor with the specified id
        var vendor = await _vendorService.GetVendorByIdAsync(searchModel.VendorId)
            ?? throw new ArgumentException("No vendor found with the specified id");

        //prepare model
        var model = await _vendorModelFactory.PrepareVendorNoteListModelAsync(searchModel, vendor);

        return Json(model);
    }

    [CheckPermission(StandardPermission.Customers.VENDORS_CREATE_EDIT_DELETE)]
    public virtual async Task<IActionResult> VendorNoteAdd(int vendorId, string message)
    {
        if (string.IsNullOrEmpty(message))
            return ErrorJson(await _localizationService.GetResourceAsync("Admin.Vendors.VendorNotes.Fields.Note.Validation"));

        //try to get a vendor with the specified id
        var vendor = await _vendorService.GetVendorByIdAsync(vendorId);
        if (vendor == null)
            return ErrorJson("Vendor cannot be loaded");

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Reload the vendor list and re-open the vendor; if it is gone, the notes request is expected to fail.
  2. Confirm the vendor was not deleted by checking the vendor grid or activity log.
  3. For programmatic callers, pre-validate the vendor id and return an empty notes list if missing.
  4. Catch ArgumentException and return a localized empty-grid JSON.

Example fix

// before
var vendor = await _vendorService.GetVendorByIdAsync(searchModel.VendorId)
    ?? throw new ArgumentException("No vendor found with the specified id");

// after
var vendor = await _vendorService.GetVendorByIdAsync(searchModel.VendorId);
if (vendor is null)
    return Json(new { Data = Enumerable.Empty<object>(), Total = 0 });
Defensive patterns

Strategy: validation

Validate before calling

var vendor = await _vendorService.GetVendorByIdAsync(searchModel.VendorId);
if (vendor is null)
    return Json(new { Data = Enumerable.Empty<object>(), Total = 0 });

Try / catch

try { await controller.VendorNotesSelect(searchModel); }
catch (ArgumentException ex) when (ex.Message.Contains("No vendor found"))
{ /* vendor deleted — return empty notes grid */ }

Prevention

When it happens

Trigger: Loading the vendor-notes sub-grid for a vendor that was deleted between the vendor-edit page load and the notes data request. Posting a VendorId that does not exist. Concurrent vendor deletion in another session while the notes panel is open.

Common situations: An admin deletes a vendor in one tab while another tab still shows the vendor-edit page with its notes panel; reloading notes triggers the request with the now-invalid id. A bulk vendor-deactivation/deletion job removed the record.

Related errors


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