nopSolutions/nopCommerce · warning · ArgumentException
No contact form attribute found with the specified id
Error message
No contact form attribute found with the specified id
What it means
Thrown by ContactFormAttributeController.ValueList (permission: MANAGE_SETTINGS). The value-grid datasource loads the parent contact-form attribute by searchModel.ContactFormAttributeId and throws ArgumentException if missing. The parent attribute was deleted or the id is invalid.
Source
Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/ContactFormAttributeController.cs:215
//activity log
await _customerActivityService.InsertActivityAsync("DeleteContactFormAttribute",
string.Format(await _localizationService.GetResourceAsync("ActivityLog.DeleteContactFormAttribute"), contactFormAttribute.Id),
contactFormAttribute);
_notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Common.ContactFormAttributes.Deleted"));
return RedirectToAction("List");
}
#endregion
#region Contact form attribute values
[HttpPost]
[CheckPermission(StandardPermission.Configuration.MANAGE_SETTINGS)]
public virtual async Task<IActionResult> ValueList(ContactFormAttributeValueSearchModel searchModel)
{
var contactFormAttribute = await _contactFormAttributeService.GetAttributeByIdAsync(searchModel.ContactFormAttributeId)
?? throw new ArgumentException("No contact form attribute found with the specified id");
//prepare model
var model = await _contactFormAttributeModelFactory.PrepareContactFormAttributeValueListModelAsync(searchModel, contactFormAttribute);
return Json(model);
}
[CheckPermission(StandardPermission.Configuration.MANAGE_SETTINGS)]
public virtual async Task<IActionResult> ValueCreatePopup(int contactFormAttributeId)
{
var contactFormAttribute = await _contactFormAttributeService.GetAttributeByIdAsync(contactFormAttributeId);
if (contactFormAttribute == null)
return RedirectToAction("List");
//prepare model
var model = await _contactFormAttributeModelFactory
.PrepareContactFormAttributeValueModelAsync(new ContactFormAttributeValueModel(), contactFormAttribute, null);
View on GitHub (pinned to 64bdf2ff08)
Solutions
- Reopen the contact-form attributes list and select a current attribute before listing its values.
- Return an empty value list instead of throwing when the parent attribute is missing.
- Verify the grid posts a valid ContactFormAttributeId after navigation.
Example fix
// before
var contactFormAttribute = await _contactFormAttributeService.GetAttributeByIdAsync(searchModel.ContactFormAttributeId)
?? throw new ArgumentException("No contact form attribute found with the specified id");
// after
var contactFormAttribute = await _contactFormAttributeService.GetAttributeByIdAsync(searchModel.ContactFormAttributeId);
if (contactFormAttribute == null)
return Json(new ContactFormAttributeValueListModel());
Defensive patterns
Strategy: validation
Validate before calling
// Validate parent contact-form attribute before listing values. var attr = await _contactFormAttributeService.GetAttributeByIdAsync(searchModel.ContactFormAttributeId); if (attr == null) return Json(new ContactFormAttributeValueListModel());
Type guard
static bool ContactFormAttributeExists(ContactFormAttribute a) => a is not null;
Try / catch
try { /* ValueList body */ }
catch (ArgumentException ex) when (ex.Message.Contains("contact form attribute"))
{
return Json(new ContactFormAttributeValueListModel());
} Prevention
- Reopen the contact-form attributes list before opening a value grid.
- Return an empty grid for a missing parent.
- Avoid deleting a parent attribute while its value tab is open.
When it happens
Trigger: POST ValueList with a ContactFormAttributeId that GetAttributeByIdAsync cannot resolve — parent attribute removed while its values tab was open, or a stale/tampered id.
Common situations: Concurrent attribute management; deleting the contact-form attribute in one tab while its value grid is mounted in another; cached client-side state.
Related errors
- No address attribute found with the specified id
- No affiliate found with the specified id
- No category found with the specified id
- No checkout attribute found with the specified id
- No contact form attribute value found with the specified id
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/79bc5355e6e22d12.
Report an issue: GitHub.