nopSolutions/nopCommerce · error · ArgumentException
No product attribute mapping found with the specified id
Error message
No product attribute mapping found with the specified id
What it means
Thrown by the GET ProductAttributeMappingEdit action when the mapping ID does not resolve to a product attribute mapping row. The action calls _productAttributeService.GetProductAttributeMappingByIdAsync(id) and uses a null-coalescing throw. This fires on the primary entity lookup — the mapping itself is missing, not its parent.
Source
Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs:3312
_notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Catalog.Products.ProductAttributes.Attributes.Added"));
if (!continueEditing)
{
//select an appropriate card
SaveSelectedCardName("product-product-attributes");
return RedirectToAction("Edit", new { id = product.Id });
}
return RedirectToAction("ProductAttributeMappingEdit", new { id = productAttributeMapping.Id });
}
[CheckPermission(StandardPermission.Catalog.PRODUCTS_VIEW)]
public virtual async Task<IActionResult> ProductAttributeMappingEdit(int id)
{
//try to get a product attribute mapping with the specified id
var productAttributeMapping = await _productAttributeService.GetProductAttributeMappingByIdAsync(id)
?? 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)
{
_notificationService.ErrorNotification(await _localizationService.GetResourceAsync("This is not your product"));
return RedirectToAction("List");
}
//prepare model
var model = await _productModelFactory.PrepareProductAttributeMappingModelAsync(null, product, productAttributeMapping);
return View(model);
}View on GitHub (pinned to 64bdf2ff08)
Solutions
- Return to the product edit page and refresh the attribute mappings grid to get current IDs.
- Replace the throw with a redirect to the product list for graceful handling.
- Check the admin log for a recent mapping deletion.
- Ensure the grid uses fresh IDs after any delete operation to avoid stale links.
Example fix
// before
var productAttributeMapping = await _productAttributeService.GetProductAttributeMappingByIdAsync(id)
?? throw new ArgumentException("No product attribute mapping found with the specified id");
// after
var productAttributeMapping = await _productAttributeService.GetProductAttributeMappingByIdAsync(id);
if (productAttributeMapping == null)
return RedirectToAction("List"); Defensive patterns
Strategy: validation
Validate before calling
// Before navigating to edit, verify the mapping exists
var mapping = await _productAttributeService.GetProductAttributeMappingByIdAsync(id);
if (mapping == null) return RedirectToAction("List"); Type guard
public static bool MappingExists(int id, ProductAttributeMapping mapping) =>
id > 0 && mapping != null; Try / catch
try
{
return await _controller.ProductAttributeMappingEdit(id);
}
catch (ArgumentException ex) when (ex.Message.Contains("No product attribute mapping found"))
{
_logger.LogInformation("Mapping {Id} not found", id);
return RedirectToAction("List");
} Prevention
- Refresh the attribute mappings grid before clicking edit.
- Replace the throw with a redirect for graceful handling.
- Use anti-forgery tokens on edit links.
When it happens
Trigger: An admin navigates to edit a product attribute mapping (GET /Admin/Product/ProductAttributeMappingEdit?id=<id>) where the mapping was already deleted or the id was tampered.
Common situations: The mapping was deleted in another tab; a stale grid link or bookmark points to a deleted mapping; the id parameter was manually edited in the URL; a browser history entry replays an old edit link.
Related errors
- No tier price found with the specified id
- No product attribute value found with the specified id
- No customer found with the specified id
- No specification attribute group found with the specified id
- No specification attribute found with the specified id
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/b5a49a674eb2708f.
Report an issue: GitHub.