{"record":{"id":"b5a49a674eb2708f","repo":"nopSolutions/nopCommerce","slug":"no-product-attribute-mapping-found-with-the-specif","errorCode":null,"errorMessage":"No product attribute mapping found with the specified id","messagePattern":"No product attribute mapping found with the specified id","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs","lineNumber":3312,"sourceCode":"\n        _notificationService.SuccessNotification(await _localizationService.GetResourceAsync(\"Admin.Catalog.Products.ProductAttributes.Attributes.Added\"));\n\n        if (!continueEditing)\n        {\n            //select an appropriate card\n            SaveSelectedCardName(\"product-product-attributes\");\n            return RedirectToAction(\"Edit\", new { id = product.Id });\n        }\n\n        return RedirectToAction(\"ProductAttributeMappingEdit\", new { id = productAttributeMapping.Id });\n    }\n\n    [CheckPermission(StandardPermission.Catalog.PRODUCTS_VIEW)]\n    public virtual async Task<IActionResult> ProductAttributeMappingEdit(int id)\n    {\n        //try to get a product attribute mapping with the specified id\n        var productAttributeMapping = await _productAttributeService.GetProductAttributeMappingByIdAsync(id)\n            ?? throw new ArgumentException(\"No product attribute mapping found with the specified id\");\n\n        //try to get a product with the specified id\n        var product = await _productService.GetProductByIdAsync(productAttributeMapping.ProductId)\n            ?? throw new ArgumentException(\"No product found with the specified id\");\n\n        //a vendor should have access only to his products\n        var currentVendor = await _workContext.GetCurrentVendorAsync();\n        if (currentVendor != null && product.VendorId != currentVendor.Id)\n        {\n            _notificationService.ErrorNotification(await _localizationService.GetResourceAsync(\"This is not your product\"));\n            return RedirectToAction(\"List\");\n        }\n\n        //prepare model\n        var model = await _productModelFactory.PrepareProductAttributeMappingModelAsync(null, product, productAttributeMapping);\n\n        return View(model);\n    }","sourceCodeStart":3294,"sourceCodeEnd":3330,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs#L3294-L3330","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar productAttributeMapping = await _productAttributeService.GetProductAttributeMappingByIdAsync(id)\n    ?? throw new ArgumentException(\"No product attribute mapping found with the specified id\");\n\n// after\nvar productAttributeMapping = await _productAttributeService.GetProductAttributeMappingByIdAsync(id);\nif (productAttributeMapping == null)\n    return RedirectToAction(\"List\");","handlingStrategy":"validation","validationCode":"// Before navigating to edit, verify the mapping exists\nvar mapping = await _productAttributeService.GetProductAttributeMappingByIdAsync(id);\nif (mapping == null) return RedirectToAction(\"List\");","typeGuard":"public static bool MappingExists(int id, ProductAttributeMapping mapping) =>\n    id > 0 && mapping != null;","tryCatchPattern":"try\n{\n    return await _controller.ProductAttributeMappingEdit(id);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"No product attribute mapping found\"))\n{\n    _logger.LogInformation(\"Mapping {Id} not found\", id);\n    return RedirectToAction(\"List\");\n}","preventionTips":["Refresh the attribute mappings grid before clicking edit.","Replace the throw with a redirect for graceful handling.","Use anti-forgery tokens on edit links."],"tags":["nopcommerce","admin-controller","argument-exception","product-attribute-mapping","edit-action"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}