nopSolutions/nopCommerce · error · ArgumentException
No product found with the specified id
Error message
No product found with the specified id
What it means
Thrown in the GET SubscribePopup action of BackInStockSubscriptionController. It loads the product by productId; if the product is null OR its Deleted flag is true it throws ArgumentException. This guards the back-in-stock subscription popup so it never renders for a missing/removed product. Because it throws rather than returning NotFound, the exception propagates to the global handler unless wrapped.
Source
Thrown at src/Presentation/Nop.Web/Controllers/BackInStockSubscriptionController.cs:71
_localizationService = localizationService;
_notificationService = notificationService;
_productService = productService;
_storeContext = storeContext;
_urlRecordService = urlRecordService;
_workContext = workContext;
}
#endregion
#region Methods
// Product details page > back in stock subscribe
[CheckLanguageSeoCode(ignore: true)]
public virtual async Task<IActionResult> SubscribePopup(int productId)
{
var product = await _productService.GetProductByIdAsync(productId);
if (product == null || product.Deleted)
throw new ArgumentException("No product found with the specified id");
var customer = await _workContext.GetCurrentCustomerAsync();
var store = await _storeContext.GetCurrentStoreAsync();
var model = new BackInStockSubscribeModel
{
ProductId = product.Id,
ProductName = await _localizationService.GetLocalizedAsync(product, x => x.Name),
ProductSeName = await _urlRecordService.GetSeNameAsync(product),
IsCurrentCustomerRegistered = await _customerService.IsRegisteredAsync(customer),
MaximumBackInStockSubscriptions = _catalogSettings.MaximumBackInStockSubscriptions,
CurrentNumberOfBackInStockSubscriptions = (await _backInStockSubscriptionService
.GetAllSubscriptionsByCustomerIdAsync(customer.Id, store.Id, 0, 1))
.TotalCount
};
if (product.ManageInventoryMethod == ManageInventoryMethod.ManageStock &&
product.BackorderMode == BackorderMode.NoBackorders &&
product.AllowBackInStockSubscriptions &&
await _productService.GetTotalStockQuantityAsync(product) <= 0)View on GitHub (pinned to 64bdf2ff08)
Solutions
- Return NotFound() or a friendly message instead of throwing ArgumentException for a public-facing popup.
- Ensure the product link is removed/redirected when the product is deleted.
- Validate productId > 0 and product existence before opening the popup on the client.
- Handle bots gracefully so deleted-product popup requests do not throw.
Example fix
// before
var product = await _productService.GetProductByIdAsync(productId);
if (product == null || product.Deleted)
throw new ArgumentException("No product found with the specified id");
// after (return NotFound for a public action)
var product = await _productService.GetProductByIdAsync(productId);
if (product == null || product.Deleted)
return NotFound(); Defensive patterns
Strategy: validation
Validate before calling
// Validate before opening the popup.
var product = await _productService.GetProductByIdAsync(productId);
if (product is null || product.Deleted)
return NotFound(); Type guard
static bool ProductAvailable(Product p) => p is not null && !p.Deleted;
Try / catch
// Throwing on a public GET is discouraged; prefer: if (product == null || product.Deleted) return NotFound();
Prevention
- Return NotFound for public-facing popup actions rather than throwing.
- Remove/redirect product URLs when the product is soft-deleted.
- Validate productId client-side before opening the popup.
When it happens
Trigger: A customer or bot requests the back-in-stock subscribe popup URL with a productId that is deleted (Deleted = true) or absent. Triggered by following an outdated product link, a product removed after the link was indexed, or a crafted/guessed id.
Common situations: Search-engine/bot hitting a cached product URL after the product was deleted; customer follows a bookmarked popup link; product soft-deleted between page load and popup open; malformed productId in query string.
Related errors
- Product not found
- No specification attribute found with the specified id
- Product is not found
- ArtificialIntelligence.CreateProductFailed
- No configuration found with the specified id
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/163bdc1b84bcd339.
Report an issue: GitHub.