nopSolutions/nopCommerce · error · ArgumentException

No specification attribute found with the specified id

Error message

No specification attribute found with the specified id

What it means

Thrown by SpecificationAttributeController.OptionList when GetSpecificationAttributeByIdAsync(searchModel.SpecificationAttributeId) returns null. This AJAX endpoint populates the options sub-grid for a given specification attribute; it requires a valid parent attribute id to scope the options list. A null parent causes an ArgumentException that surfaces as HTTP 500.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/SpecificationAttributeController.cs:379

        
        //activity log
        var activityLogFormat = await _localizationService.GetResourceAsync("ActivityLog.DeleteSpecAttribute");
        await _customerActivityService.InsertActivitiesAsync("DeleteSpecAttribute", specificationAttributes, specificationAttribute => string.Format(activityLogFormat, specificationAttribute.Name));

        return Json(new { Result = true });
    }

    #endregion

    #region Specification attribute options

    [HttpPost]
    [CheckPermission(StandardPermission.Catalog.SPECIFICATION_ATTRIBUTES_VIEW)]
    public virtual async Task<IActionResult> OptionList(SpecificationAttributeOptionSearchModel searchModel)
    {
        //try to get a specification attribute with the specified id
        var specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(searchModel.SpecificationAttributeId)
            ?? throw new ArgumentException("No specification attribute found with the specified id");

        //prepare model
        var model = await _specificationAttributeModelFactory.PrepareSpecificationAttributeOptionListModelAsync(searchModel, specificationAttribute);

        return Json(model);
    }

    [CheckPermission(StandardPermission.Catalog.SPECIFICATION_ATTRIBUTES_CREATE_EDIT_DELETE)]
    public virtual async Task<IActionResult> OptionCreatePopup(int specificationAttributeId)
    {
        //try to get a specification attribute with the specified id
        var specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(specificationAttributeId);
        if (specificationAttribute == null)
            return RedirectToAction("List");

        //prepare model
        var model = await _specificationAttributeModelFactory
            .PrepareSpecificationAttributeOptionModelAsync(new SpecificationAttributeOptionModel(), specificationAttribute, null);

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Reload the specification attributes list page; the stale attribute id will no longer appear and the options grid will not be requested for it.
  2. Confirm the attribute was not intentionally deleted; if so, recreate it or adjust dependent products.
  3. For programmatic access, pre-validate the attribute id and return an empty result set rather than triggering the exception.
  4. Add a try-catch in the action returning a localized empty-grid JSON on ArgumentException.

Example fix

// before
var specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(searchModel.SpecificationAttributeId)
    ?? throw new ArgumentException("No specification attribute found with the specified id");

// after
var specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(searchModel.SpecificationAttributeId);
if (specificationAttribute is null)
    return Json(new { Data = Enumerable.Empty<object>(), Total = 0 });
Defensive patterns

Strategy: validation

Validate before calling

var attr = await _specificationAttributeService
    .GetSpecificationAttributeByIdAsync(searchModel.SpecificationAttributeId);
if (attr is null)
    return; // parent attribute deleted — skip options grid

Try / catch

try { await controller.OptionList(searchModel); }
catch (ArgumentException ex) when (ex.Message.Contains("No specification attribute found"))
{ /* parent attribute gone — return empty options */ }

Prevention

When it happens

Trigger: Loading the options grid for a specification attribute that was deleted in another admin session, or posting a SpecificationAttributeId that never existed. Commonly hit when the parent attribute row is removed while its child-options grid panel is still open or being reloaded.

Common situations: An admin deletes a specification attribute in one tab while the options sub-grid for that attribute is open in another. A page that was left open with a now-stale attribute id is re-expanded after a rebind. A migration/import altered attribute ids, breaking stored references.

Related errors


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