nopSolutions/nopCommerce · error · ArgumentException

No setting found with the specified id

Error message

No setting found with the specified id

What it means

Thrown by SettingUpdate (POST, MANAGE_SETTINGS) when GetSettingByIdAsync(model.Id) returns null. The action edits a single setting row; if the id does not match an existing Setting (deleted between grid render and save, or tampered), it throws ArgumentException. Note the action then may delete-and-recreate the setting if the name changed.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/SettingController.cs:1915

    [CheckPermission(StandardPermission.Configuration.MANAGE_SETTINGS)]
    public virtual async Task<IActionResult> AllSettings(SettingSearchModel searchModel)
    {
        //prepare model
        var model = await _settingModelFactory.PrepareSettingListModelAsync(searchModel);

        return Json(model);
    }

    [HttpPost]
    [CheckPermission(StandardPermission.Configuration.MANAGE_SETTINGS)]
    public virtual async Task<IActionResult> SettingUpdate(SettingModel model)
    {
        if (!ModelState.IsValid)
            return ErrorJson(ModelState.SerializeErrors());

        //try to get a setting with the specified id
        var setting = await _settingService.GetSettingByIdAsync(model.Id)
            ?? throw new ArgumentException("No setting found with the specified id");

        if (!setting.Name.Equals(model.Name, StringComparison.InvariantCultureIgnoreCase))
        {
            //setting name has been changed
            await _settingService.DeleteSettingAsync(setting);
        }

        await _settingService.SetSettingAsync(model.Name, model.Value, setting.StoreId);

        //activity log
        await _customerActivityService.InsertActivityAsync("EditSettings", await _localizationService.GetResourceAsync("ActivityLog.EditSettings"), setting);

        return new NullJsonResult();
    }

    [HttpPost]
    [CheckPermission(StandardPermission.Configuration.MANAGE_SETTINGS)]
    public virtual async Task<IActionResult> SettingAdd(SettingModel model)

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Refresh the all-settings grid before editing a row.
  2. Validate model.Id resolves to a setting before submitting the edit.
  3. Make the update tolerant: treat missing as 'recreate from model' or return ErrorJson.
  4. Avoid deleting settings while inline edits are pending.

Example fix

// before
var setting = await _settingService.GetSettingByIdAsync(model.Id)
    ?? throw new ArgumentException("No setting found with the specified id");

// after
var setting = await _settingService.GetSettingByIdAsync(model.Id);
if (setting == null)
    return ErrorJson("Setting no longer exists; refresh the grid.");
Defensive patterns

Strategy: validation

Validate before calling

if (model.Id <= 0) return ErrorJson("Invalid setting id.");
var setting = await _settingService.GetSettingByIdAsync(model.Id);
if (setting == null) return ErrorJson("Setting no longer exists.");

Type guard

// N/A

Try / catch

catch (ArgumentException ex) when (ex.Message.Contains("No setting found"))
{ return ErrorJson(ex.Message); }

Prevention

When it happens

Trigger: Inline-editing a setting row whose underlying Setting was removed; tampered model.Id; settings cleared by a reset/migration while the all-settings grid was open; another admin deleted the row.

Common situations: Concurrent settings edits; restored DBs; plugin uninstalls that removed their settings rows; fixtures with stale ids.

Related errors


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