{"record":{"id":"b882d1867c763f08","repo":"nopSolutions/nopCommerce","slug":"no-cross-sell-product-found-with-the-specified-id","errorCode":null,"errorMessage":"No cross-sell product found with the specified id","messagePattern":"No cross-sell 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":1822,"sourceCode":"\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.PrepareCrossSellProductListModelAsync(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> CrossSellProductDelete(int id)\n    {\n        //try to get a cross-sell product with the specified id\n        var crossSellProduct = await _productService.GetCrossSellProductByIdAsync(id)\n            ?? throw new ArgumentException(\"No cross-sell 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)\n        {\n            var product = await _productService.GetProductByIdAsync(crossSellProduct.ProductId1);\n            if (product != null && product.VendorId != currentVendor.Id)\n                return Content(\"This is not your product\");\n        }\n\n        await _productService.DeleteCrossSellProductAsync(crossSellProduct);\n\n        return new NullJsonResult();\n    }\n\n    [CheckPermission(StandardPermission.Catalog.PRODUCTS_CREATE_EDIT_DELETE)]\n    public virtual async Task<IActionResult> CrossSellProductAddPopup(int productId)\n    {","sourceCodeStart":1804,"sourceCodeEnd":1840,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs#L1804-L1840","documentation":"Thrown by the CrossSellProductDelete action when _productService.GetCrossSellProductByIdAsync(id) returns null (?? throw new ArgumentException). This AJAX delete handler removes a cross-sell product mapping. The uncaught ArgumentException surfaces as an HTTP 500 to the grid delete request.","triggerScenarios":"POST to delete a cross-sell mapping by id that no longer exists — already deleted, duplicate delete, or stale grid row.","commonSituations":"Double-click on delete; concurrent admins deleting the same mapping; scripted bulk delete revisiting an id; a grid not refreshed after a prior delete.","solutions":["Reload the grid — the mapping is already removed; treat as success.","Make delete idempotent by returning NullJsonResult when the mapping is null.","Disable the delete control client-side after the first click.","In automation, tolerate 'already deleted' instead of erroring."],"exampleFix":"// before\nvar crossSellProduct = await _productService.GetCrossSellProductByIdAsync(id)\n    ?? throw new ArgumentException(\"No cross-sell product found with the specified id\");\n\n// after — idempotent delete\nvar crossSellProduct = await _productService.GetCrossSellProductByIdAsync(id);\nif (crossSellProduct == null)\n    return new NullJsonResult();","handlingStrategy":"validation","validationCode":"// Idempotent delete: tolerate already-removed cross-sell mappings\nvar crossSellProduct = await _productService.GetCrossSellProductByIdAsync(id);\nif (crossSellProduct == null)\n    return new NullJsonResult(); // already deleted","typeGuard":"if (id <= 0) return BadRequest(\"Invalid cross-sell product id\");","tryCatchPattern":"try { var csp = await _productService.GetCrossSellProductByIdAsync(id); if (csp == null) return new NullJsonResult(); await _productService.DeleteCrossSellProductAsync(csp); ... } catch (ArgumentException) { return new NullJsonResult(); }","preventionTips":["Make delete handlers idempotent — a missing entity should be a no-op success.","Disable the delete control after first click to prevent duplicates.","Reload the grid after each delete."],"tags":["nopcommerce","admin","product","cross-sell","entity-not-found","argumentexception","delete","idempotency"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}