nopSolutions/nopCommerce · error · ArgumentException

No product attribute value found with the specified id

Error message

No product attribute value found with the specified id

What it means

Thrown by ProductAttributeValueDelete (POST) when _productAttributeService.GetProductAttributeValueByIdAsync(id) returns null. The action expects a valid ProductAttributeValue id from the request body; a missing/stale/deleted row produces this ArgumentException, which propagates as a 500 to the admin UI. It is the first of a three-stage cascade (value -> mapping -> product) used to authorize and scope the delete operation.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs:3658

            ViewBag.RefreshPage = true;

            return View(model);
        }

        //prepare model
        model = await _productModelFactory.PrepareProductAttributeValueModelAsync(model, productAttributeMapping, productAttributeValue, true);

        //if we got this far, something failed, redisplay form
        return View(model);
    }

    [HttpPost]
    [CheckPermission(StandardPermission.Catalog.PRODUCTS_CREATE_EDIT_DELETE)]
    public virtual async Task<IActionResult> ProductAttributeValueDelete(int id)
    {
        //try to get a product attribute value with the specified id
        var productAttributeValue = await _productAttributeService.GetProductAttributeValueByIdAsync(id)
            ?? throw new ArgumentException("No product attribute value found with the specified id");

        //try to get a product attribute mapping with the specified id
        var productAttributeMapping = await _productAttributeService.GetProductAttributeMappingByIdAsync(productAttributeValue.ProductAttributeMappingId)
            ?? throw new ArgumentException("No product attribute mapping found with the specified id");

        //try to get a product with the specified id
        var product = await _productService.GetProductByIdAsync(productAttributeMapping.ProductId)
            ?? throw new ArgumentException("No product found with the specified id");

        //a vendor should have access only to his products
        var currentVendor = await _workContext.GetCurrentVendorAsync();
        if (currentVendor != null && product.VendorId != currentVendor.Id)
            return Content("This is not your product");

        //check if existed combinations contains the specified attribute value
        var existedCombinations = await _productAttributeService.GetAllProductAttributeCombinationsAsync(product.Id);
        if (existedCombinations?.Any() == true)
        {

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Refresh the product attribute values list and re-issue the delete against a current id.
  2. Verify the id is non-zero and corresponds to an existing ProductAttributeValue before posting.
  3. Check whether another admin or a bulk operation already removed that attribute value.
  4. If reproducing via API/tooling, confirm you are calling the action with the correct `{ id }` form field name.

Example fix

// before
var productAttributeValue = await _productAttributeService.GetProductAttributeValueByIdAsync(id)
    ?? throw new ArgumentException("No product attribute value found with the specified id");

// after (graceful 404 instead of 500)
var productAttributeValue = await _productAttributeService.GetProductAttributeValueByIdAsync(id);
if (productAttributeValue == null)
    return NotFound($"No product attribute value found with id {id}");
Defensive patterns

Strategy: validation

Validate before calling

var value = await _productAttributeService.GetProductAttributeValueByIdAsync(id);
if (value == null)
    return NotFound();
// proceed with delete

Type guard

// N/A - id is a primitive int; guard with existence check, not a type guard.

Try / catch

try { /* delete */ }
catch (ArgumentException ex) when (ex.Message.Contains("No product attribute value"))
{ return NotFound(ex.Message); }

Prevention

When it happens

Trigger: POST to admin ProductAttributeValueDelete with an `id` that is 0, negative, references an already-deleted ProductAttributeValue, or is forged by a tampered grid row. Also triggered when two admins race: one deletes the value while the other's grid still lists it.

Common situations: Concurrent edits in the admin product-attribute grid; stale browser tabs after a value was removed; automated/scripted calls replaying an old id; corrupted bookmarks pointing at deleted values.

Related errors


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