nopSolutions/nopCommerce · error · ArgumentException

No vendor attribute found with the specified id

Error message

No vendor attribute found with the specified id

What it means

Thrown by VendorAttributeController.ValueList when IVendorAttributeService.GetAttributeByIdAsync(searchModel.VendorAttributeId) returns null. This AJAX grid endpoint (behind MANAGE_SETTINGS permission) lists the values/options for a given vendor attribute; a missing parent attribute yields ArgumentException before the value-list model is prepared.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/VendorAttributeController.cs:220

        await _customerActivityService.InsertActivityAsync("DeleteVendorAttribute",
            string.Format(await _localizationService.GetResourceAsync("ActivityLog.DeleteVendorAttribute"), vendorAttribute.Id), vendorAttribute);

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

        return RedirectToAction("List");
    }

    #endregion

    #region Vendor attribute values

    [HttpPost]
    [CheckPermission(StandardPermission.Configuration.MANAGE_SETTINGS)]
    public virtual async Task<IActionResult> ValueList(VendorAttributeValueSearchModel searchModel)
    {
        //try to get a vendor attribute with the specified id
        var vendorAttribute = await _vendorAttributeService.GetAttributeByIdAsync(searchModel.VendorAttributeId)
            ?? throw new ArgumentException("No vendor attribute found with the specified id");

        //prepare model
        var model = await _vendorAttributeModelFactory.PrepareVendorAttributeValueListModelAsync(searchModel, vendorAttribute);

        return Json(model);
    }

    [CheckPermission(StandardPermission.Configuration.MANAGE_SETTINGS)]
    public virtual async Task<IActionResult> ValueCreatePopup(int vendorAttributeId)
    {
        //try to get a vendor attribute with the specified id
        var vendorAttribute = await _vendorAttributeService.GetAttributeByIdAsync(vendorAttributeId);
        if (vendorAttribute == null)
            return RedirectToAction("List");

        //prepare model
        var model = await _vendorAttributeModelFactory.PrepareVendorAttributeValueModelAsync(new VendorAttributeValueModel(), vendorAttribute, null);

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Reload the vendor attributes page so the deleted attribute and its stale sub-grid reference are removed.
  2. Confirm the attribute id is still valid before relying on the values grid.
  3. For custom integrations, pre-check the attribute existence and return an empty list if missing.
  4. Catch ArgumentException and return a localized empty-grid JSON.

Example fix

// before
var vendorAttribute = await _vendorAttributeService.GetAttributeByIdAsync(searchModel.VendorAttributeId)
    ?? throw new ArgumentException("No vendor attribute found with the specified id");

// after
var vendorAttribute = await _vendorAttributeService.GetAttributeByIdAsync(searchModel.VendorAttributeId);
if (vendorAttribute is null)
    return Json(new { Data = Enumerable.Empty<object>(), Total = 0 });
Defensive patterns

Strategy: validation

Validate before calling

var attr = await _vendorAttributeService.GetAttributeByIdAsync(searchModel.VendorAttributeId);
if (attr is null)
    return Json(new { Data = Enumerable.Empty<object>(), Total = 0 });

Try / catch

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

Prevention

When it happens

Trigger: Loading the vendor-attribute-values sub-grid for a vendor attribute that was deleted between the parent page load and the sub-grid data request. Posting a VendorAttributeId that does not exist or was reassigned. Concurrent deletion from another session.

Common situations: An admin deletes a vendor attribute in one tab while another tab has its values panel open; reloading that panel triggers the request with the now-invalid id. An import/migration renumbers vendor attribute ids, breaking cached sub-grid references.

Related errors


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