{"record":{"id":"e596c2c57e62c70a","repo":"nopSolutions/nopCommerce","slug":"no-specification-attribute-found-with-the-specifie-e596c2","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/Factories/ProductModelFactory.cs","lineNumber":1733,"sourceCode":"    {\n        if (!specificationId.HasValue)\n        {\n            return new AddSpecificationAttributeModel\n            {\n                AvailableAttributes = await (await _specificationAttributeService.GetSpecificationAttributesWithOptionsAsync())\n                    .SelectAwait(async attributeWithOption =>\n                    {\n                        var attributeName = await GetSpecificationAttributeNameAsync(attributeWithOption);\n\n                        return new SelectListItem(attributeName, attributeWithOption.Id.ToString());\n                    }).ToListAsync(),\n                ProductId = productId,\n                Locales = await _localizedModelFactory.PrepareLocalizedModelsAsync<AddSpecificationAttributeLocalizedModel>()\n            };\n        }\n\n        var attribute = await _specificationAttributeService.GetProductSpecificationAttributeByIdAsync(specificationId.Value)\n            ?? throw new ArgumentException(\"No specification attribute found with the specified id\");\n\n        //a vendor should have access only to his products\n        var currentVendor = await _workContext.GetCurrentVendorAsync();\n        if (currentVendor != null && (await _productService.GetProductByIdAsync(attribute.ProductId)).VendorId != currentVendor.Id)\n            throw new UnauthorizedAccessException(\"This is not your product\");\n\n        var specAttributeOption = await _specificationAttributeService.GetSpecificationAttributeOptionByIdAsync(attribute.SpecificationAttributeOptionId);\n        var specAttribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(specAttributeOption.SpecificationAttributeId);\n\n        var model = attribute.ToModel<AddSpecificationAttributeModel>();\n        model.SpecificationId = attribute.Id;\n        model.AttributeId = specAttribute.Id;\n        model.AttributeTypeName = await _localizationService.GetLocalizedEnumAsync(attribute.AttributeType);\n        model.AttributeName = specAttribute.Name;\n\n        model.AvailableAttributes = await (await _specificationAttributeService.GetSpecificationAttributesWithOptionsAsync())\n            .SelectAwait(async attributeWithOption =>\n            {","sourceCodeStart":1715,"sourceCodeEnd":1751,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductModelFactory.cs#L1715-L1751","documentation":"Thrown in PrepareAddSpecificationAttributeModelAsync when editing an existing product specification attribute. The factory loads the attribute by specificationId via GetProductSpecificationAttributeByIdAsync; if null (the id does not match any ProductSpecificationAttribute row) it throws ArgumentException. This typically means the requested specification id was deleted, the URL/query id is stale, or the value was never persisted.","triggerScenarios":"An admin request to edit a product specification attribute supplies a specificationId that resolves to no ProductSpecificationAttribute row. Triggered by following a stale edit link, deleting the attribute in another tab, or a malformed/guessed id.","commonSituations":"Concurrent admin edits where one user deletes the attribute while another opens its editor; bookmarked edit URLs after the attribute was removed; a bad/templated id passed from a custom integration; race between load and edit.","solutions":["Refresh the product specification list; the attribute no longer exists, so reopen a valid one.","Verify the specificationId in the request corresponds to an existing ProductSpecificationAttribute row.","Add a not-found guard that returns a friendly 'record no longer exists' message instead of an unhandled ArgumentException.","Avoid deep-linking edit popups; always navigate from the current grid."],"exampleFix":"// before\nvar attribute = await _specificationAttributeService.GetProductSpecificationAttributeByIdAsync(specificationId.Value)\n    ?? throw new ArgumentException(\"No specification attribute found with the specified id\");\n// after (guard and redirect with message)\nvar attribute = await _specificationAttributeService.GetProductSpecificationAttributeByIdAsync(specificationId.Value);\nif (attribute is null)\n{\n    _notificationService.ErrorNotification(\"The specification attribute no longer exists.\");\n    return RedirectToRoute(/* product spec list */);\n}","handlingStrategy":"validation","validationCode":"// Validate the specification id before loading the editor.\nvar attribute = await _specificationAttributeService.GetProductSpecificationAttributeByIdAsync(specificationId.Value);\nif (attribute is null)\n{\n    _notificationService.ErrorNotification(\"This specification attribute no longer exists.\");\n    return; // or redirect to the list\n}","typeGuard":"static bool SpecAttributeExists(ProductSpecificationAttribute a) => a is not null;","tryCatchPattern":"try { /* PrepareAddSpecificationAttributeModelAsync body */ }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"specification attribute\"))\n{\n    _notificationService.ErrorNotification(ex.Message);\n}","preventionTips":["Always navigate to the edit popup from the live grid, not a bookmarked id.","Handle the 'deleted in another tab' case by re-checking existence before edit.","Return a redirect/message instead of throwing ArgumentException for admin edit actions."],"tags":["nopcommerce","admin","product","specification-attribute","not-found","concurrency"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}