nopSolutions/nopCommerce · error · ArgumentException

No product picture found with the specified id

Error message

No product picture found with the specified id

What it means

Thrown by ProductPictureUpdate when _productService.GetProductPictureByIdAsync(model.Id) returns null. model.Id is the ProductPicture mapping row being edited (DisplayOrder/alt/title overrides), posted from the grid inline editor.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs:2203

        //a vendor should have access only to his products
        var currentVendor = await _workContext.GetCurrentVendorAsync();
        if (currentVendor != null && product.VendorId != currentVendor.Id)
            return Content("This is not your product");

        //prepare model
        var model = await _productModelFactory.PrepareProductPictureListModelAsync(searchModel, product);

        return Json(model);
    }

    [HttpPost]
    [CheckPermission(StandardPermission.Catalog.PRODUCTS_CREATE_EDIT_DELETE)]
    public virtual async Task<IActionResult> ProductPictureUpdate(ProductPictureModel model)
    {
        //try to get a product picture with the specified id
        var productPicture = await _productService.GetProductPictureByIdAsync(model.Id)
            ?? throw new ArgumentException("No product picture found with the specified id");

        //a vendor should have access only to his products
        var currentVendor = await _workContext.GetCurrentVendorAsync();
        if (currentVendor != null)
        {
            var product = await _productService.GetProductByIdAsync(productPicture.ProductId);
            if (product != null && product.VendorId != currentVendor.Id)
                return Content("This is not your product");
        }

        //try to get a picture with the specified id
        var picture = await _pictureService.GetPictureByIdAsync(productPicture.PictureId)
            ?? throw new ArgumentException("No picture found with the specified id");

        await _pictureService.UpdatePictureAsync(picture.Id,
            await _pictureService.LoadPictureBinaryAsync(picture),
            picture.MimeType,
            picture.SeoFilename,

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Refresh the pictures grid before inline-editing a row.
  2. Replace the throw with a null check returning Json(new { success = false }).
  3. Avoid concurrent picture management on the same product.
  4. Coalesce bulk picture operations so they don't interleave with manual edits.

Example fix

// before
var productPicture = await _productService.GetProductPictureByIdAsync(model.Id)
    ?? throw new ArgumentException("No product picture found with the specified id");

// after
var productPicture = await _productService.GetProductPictureByIdAsync(model.Id);
if (productPicture == null)
    return Json(new { success = false, message = "Picture mapping no longer exists." });
Defensive patterns

Strategy: validation

Validate before calling

var productPicture = await _productService.GetProductPictureByIdAsync(model.Id);
if (productPicture == null)
    return Json(new { success = false, message = "Picture mapping no longer exists." });

Try / catch

try { /* update */ }
catch (ArgumentException ex) when (ex.Message.Contains("product picture"))
    return Json(new { success = false, message = ex.Message });

Prevention

When it happens

Trigger: POST Admin/Product/ProductPictureUpdate with model.Id of a ProductPicture row that was removed (picture deleted, product saved, mapping cleaned) between grid render and update post. Concurrent edits on the same pictures grid.

Common situations: Two operators on the same product's pictures; one deletes a picture while the other edits its DisplayOrder. Reordering after a picture cleanup script ran.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/ce70b0d6aa8cf946. Report an issue: GitHub.