{"record":{"id":"04d2382891b84d89","repo":"nopSolutions/nopCommerce","slug":"no-product-found-with-the-specified-id-04d238","errorCode":null,"errorMessage":"No product found with the specified id","messagePattern":"No product found with the specified id","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs","lineNumber":1681,"sourceCode":"    public virtual async Task<IActionResult> RequiredProductAddPopupList(AddRequiredProductSearchModel searchModel)\n    {\n        //prepare model\n        var model = await _productModelFactory.PrepareAddRequiredProductListModelAsync(searchModel);\n\n        return Json(model);\n    }\n\n    #endregion\n\n    #region Related products\n\n    [HttpPost]\n    [CheckPermission(StandardPermission.Catalog.PRODUCTS_VIEW)]\n    public virtual async Task<IActionResult> RelatedProductList(RelatedProductSearchModel searchModel)\n    {\n        //try to get a product with the specified id\n        var product = await _productService.GetProductByIdAsync(searchModel.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            return Content(\"This is not your product\");\n\n        //prepare model\n        var model = await _productModelFactory.PrepareRelatedProductListModelAsync(searchModel, product);\n\n        return Json(model);\n    }\n\n    [HttpPost]\n    [CheckPermission(StandardPermission.Catalog.PRODUCTS_CREATE_EDIT_DELETE)]\n    public virtual async Task<IActionResult> RelatedProductUpdate(RelatedProductModel model)\n    {\n        //try to get a related product with the specified id\n        var relatedProduct = await _productService.GetRelatedProductByIdAsync(model.Id)","sourceCodeStart":1663,"sourceCodeEnd":1699,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs#L1663-L1699","documentation":"Thrown by the RelatedProductList grid action when _productService.GetProductByIdAsync(searchModel.ProductId) returns null (?? throw new ArgumentException). This POST action loads the 'Related products' tab grid for a given product via AJAX. The ArgumentException is uncaught locally and propagates as an HTTP 500 / JSON error to the grid.","triggerScenarios":"POST to the related-product list with a ProductId that resolves to no product — the product was deleted, the ID is stale, or the request was tampered.","commonSituations":"Concurrent admin edits where the product is deleted while its edit page is open elsewhere; a stale/bookmarked product URL; integration tests or scripts hitting the endpoint with a non-existent ProductId.","solutions":["Refresh the product list and re-open a valid product — the ID is likely stale or the product deleted.","Verify the ProductId in the request corresponds to an existing product.","When integrating, call GetProductByIdAsync first and handle null gracefully.","Replace the throw with a NullJsonResult or BadRequest for a friendlier grid error."],"exampleFix":"// before\nvar product = await _productService.GetProductByIdAsync(searchModel.ProductId)\n    ?? throw new ArgumentException(\"No product found with the specified id\");\n\n// after\nvar product = await _productService.GetProductByIdAsync(searchModel.ProductId);\nif (product == null)\n    return BadRequest(\"No product found with the specified id\");","handlingStrategy":"validation","validationCode":"// Before loading the grid: confirm the product exists\nvar product = await _productService.GetProductByIdAsync(searchModel.ProductId);\nif (product == null)\n    return BadRequest(\"No product found with the specified id\");","typeGuard":"if (searchModel.ProductId <= 0) return BadRequest(\"Invalid product id\");","tryCatchPattern":"try { var product = await _productService.GetProductByIdAsync(searchModel.ProductId) ?? throw new ArgumentException(); ... } catch (ArgumentException) { return BadRequest(\"No product found with the specified id\"); }","preventionTips":["Reopen the product from a fresh list to avoid stale IDs.","Validate the parent product id on the client before issuing the AJAX grid request.","Return BadRequest/NullJsonResult on a missing parent rather than throwing."],"tags":["nopcommerce","admin","product","related-products","entity-not-found","argumentexception","ajax-grid"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}