nopSolutions/nopCommerce · error · ArgumentException

No slides found with the specified picture id

Error message

No slides found with the specified picture id

What it means

Thrown by the Swiper SlideEdit POST action (guarded by MANAGE_WIDGETS). After loading the store's slides, the controller looks for a slide whose PictureId equals model.PictureId; if none matches it throws ArgumentException. It indicates the edit form submitted a PictureId that is not present in the current store scope's slide list.

Source

Thrown at src/Plugins/Nop.Plugin.Widgets.Swiper/Controllers/WidgetSwiperController.cs:240

        }

        return new NullJsonResult();
    }

    [HttpPost]
    [CheckPermission(StandardPermission.Configuration.MANAGE_WIDGETS)]
    public virtual async Task<IActionResult> SlideEdit(SlidePictureModel model)
    {
        //load settings for a chosen store scope
        var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync();

        var slides = await GetSlidesForStoreAsync(storeScope);
        if (!slides?.Any() == true)
            return Content("No slides");

        //try to get a picture with the specified id
        var slide = slides.FirstOrDefault(s => s.PictureId == model.PictureId)
            ?? throw new ArgumentException("No slides found with the specified picture id");

        slide.TitleText = model.TitleText;
        slide.AltText = model.AltText;
        slide.LinkUrl = model.LinkUrl;

        var sliderSettings = await _settingService.LoadSettingAsync<SwiperSettings>(storeScope);
        sliderSettings.Slides = JsonConvert.SerializeObject(slides);
        await _settingService.SaveSettingOverridablePerStoreAsync(sliderSettings, x => x.Slides, true, storeScope);

        return new NullJsonResult();
    }

    #endregion
}

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Reload the slide list in admin before editing so the form carries a current PictureId for the active store scope.
  2. Verify the store scope selector matches the scope that owns the target slide.
  3. Make the action defensive: return a NotFound/Json error instead of throwing when no slide matches (see exampleFix).

Example fix

// before
var slide = slides.FirstOrDefault(s => s.PictureId == model.PictureId)
    ?? throw new ArgumentException("No slides found with the specified picture id");

// after
var slide = slides?.FirstOrDefault(s => s.PictureId == model.PictureId);
if (slide == null)
    return NotFound($"No slide for picture {model.PictureId} in store {storeScope}");
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the submitted PictureId belongs to the active store's slides before mutating.
var slides = await GetSlidesForStoreAsync(storeScope);
if (slides?.Any(s => s.PictureId == model.PictureId) != true)
    return NotFound("Slide not found for this store scope.");

Type guard

static bool SlideMatchesStoreScope(IEnumerable<Slide> slides, int pictureId)
    => slides?.Any(s => s.PictureId == pictureId) == true;

Try / catch

try { /* SlideEdit body */ }
catch (ArgumentException ex) when (ex.Message == "No slides found with the specified picture id")
{
    return BadRequest($"Slide for picture {model.PictureId} not found in store {storeScope}.");
}

Prevention

When it happens

Trigger: POST SlideEdit with a model.PictureId that does not match any slide in GetSlidesForStoreAsync(storeScope). Happens when the slide was edited/deleted in another store scope, or the client sends a PictureId from a different/removed slide.

Common situations: Multi-store setups where slides differ per store; an admin has two browser tabs open against different store scopes; the slides JSON was changed out-of-band and a stale form was submitted.

Related errors


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