{"record":{"id":"9e81b64908cdf196","repo":"nopSolutions/nopCommerce","slug":"no-specification-attribute-found-with-the-specifie","errorCode":null,"errorMessage":"No specification attribute found with the specified id","messagePattern":"No specification attribute found with the specified id","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Presentation/Nop.Web/Areas/Admin/Controllers/SpecificationAttributeController.cs","lineNumber":379,"sourceCode":"        \n        //activity log\n        var activityLogFormat = await _localizationService.GetResourceAsync(\"ActivityLog.DeleteSpecAttribute\");\n        await _customerActivityService.InsertActivitiesAsync(\"DeleteSpecAttribute\", specificationAttributes, specificationAttribute => string.Format(activityLogFormat, specificationAttribute.Name));\n\n        return Json(new { Result = true });\n    }\n\n    #endregion\n\n    #region Specification attribute options\n\n    [HttpPost]\n    [CheckPermission(StandardPermission.Catalog.SPECIFICATION_ATTRIBUTES_VIEW)]\n    public virtual async Task<IActionResult> OptionList(SpecificationAttributeOptionSearchModel searchModel)\n    {\n        //try to get a specification attribute with the specified id\n        var specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(searchModel.SpecificationAttributeId)\n            ?? throw new ArgumentException(\"No specification attribute found with the specified id\");\n\n        //prepare model\n        var model = await _specificationAttributeModelFactory.PrepareSpecificationAttributeOptionListModelAsync(searchModel, specificationAttribute);\n\n        return Json(model);\n    }\n\n    [CheckPermission(StandardPermission.Catalog.SPECIFICATION_ATTRIBUTES_CREATE_EDIT_DELETE)]\n    public virtual async Task<IActionResult> OptionCreatePopup(int specificationAttributeId)\n    {\n        //try to get a specification attribute with the specified id\n        var specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(specificationAttributeId);\n        if (specificationAttribute == null)\n            return RedirectToAction(\"List\");\n\n        //prepare model\n        var model = await _specificationAttributeModelFactory\n            .PrepareSpecificationAttributeOptionModelAsync(new SpecificationAttributeOptionModel(), specificationAttribute, null);","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Controllers/SpecificationAttributeController.cs#L361-L397","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reload the specification attributes list page; the stale attribute id will no longer appear and the options grid will not be requested for it.","Confirm the attribute was not intentionally deleted; if so, recreate it or adjust dependent products.","For programmatic access, pre-validate the attribute id and return an empty result set rather than triggering the exception.","Add a try-catch in the action returning a localized empty-grid JSON on ArgumentException."],"exampleFix":"// before\nvar specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(searchModel.SpecificationAttributeId)\n    ?? throw new ArgumentException(\"No specification attribute found with the specified id\");\n\n// after\nvar specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(searchModel.SpecificationAttributeId);\nif (specificationAttribute is null)\n    return Json(new { Data = Enumerable.Empty<object>(), Total = 0 });","handlingStrategy":"validation","validationCode":"var attr = await _specificationAttributeService\n    .GetSpecificationAttributeByIdAsync(searchModel.SpecificationAttributeId);\nif (attr is null)\n    return; // parent attribute deleted — skip options grid","typeGuard":null,"tryCatchPattern":"try { await controller.OptionList(searchModel); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"No specification attribute found\"))\n{ /* parent attribute gone — return empty options */ }","preventionTips":["Reload the specification attributes page after deleting one to clear stale sub-grid references.","Handle the options-grid AJAX failure with an empty-result fallback.","Cascade-clear child panels when a parent attribute is deleted."],"tags":["nopcommerce","admin-controller","not-found","specification-attribute","options","argument-exception"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}