nopSolutions/nopCommerce · warning · ArgumentException

No contact form attribute value found with the specified id

Error message

No contact form attribute value found with the specified id

What it means

Thrown by ContactFormAttributeController.ValueDelete (permission: MANAGE_SETTINGS). It fetches the contact-form attribute value by id and throws ArgumentException if missing — the value was already deleted or the id is invalid.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/ContactFormAttributeController.cs:326

            ViewBag.RefreshPage = true;

            return View(model);
        }

        //prepare model
        model = await _contactFormAttributeModelFactory.PrepareContactFormAttributeValueModelAsync(model, contactFormAttribute, contactFormAttributeValue, true);

        //if we got this far, something failed, redisplay form
        return View(model);
    }

    [HttpPost]
    [CheckPermission(StandardPermission.Configuration.MANAGE_SETTINGS)]
    public virtual async Task<IActionResult> ValueDelete(int id)
    {
        var contactFormAttributeValue = await _contactFormAttributeService.GetAttributeValueByIdAsync(id)
            ?? throw new ArgumentException("No contact form attribute value found with the specified id", nameof(id));

        await _contactFormAttributeService.DeleteAttributeValueAsync(contactFormAttributeValue);

        //activity log
        await _customerActivityService.InsertActivityAsync("DeleteContactFormAttributeValue",
            string.Format(await _localizationService.GetResourceAsync("ActivityLog.DeleteContactFormAttributeValue"), contactFormAttributeValue.Id),
            contactFormAttributeValue);

        return new NullJsonResult();
    }

    #endregion
}

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Refresh the value grid and delete only rows that still appear.
  2. Make ValueDelete idempotent (return success when the row is already gone).
  3. Disable the delete control after first click and handle missing-row responses gracefully.

Example fix

// before
var contactFormAttributeValue = await _contactFormAttributeService.GetAttributeValueByIdAsync(id)
    ?? throw new ArgumentException("No contact form attribute value found with the specified id", nameof(id));

// after
var contactFormAttributeValue = await _contactFormAttributeService.GetAttributeValueByIdAsync(id);
if (contactFormAttributeValue == null)
    return new NullJsonResult();
Defensive patterns

Strategy: fallback

Validate before calling

// Idempotent contact-form attribute value delete.
var value = await _contactFormAttributeService.GetAttributeValueByIdAsync(id);
if (value == null) return new NullJsonResult();

Type guard

static bool ContactFormAttributeValueExists(ContactFormAttributeValue v) => v is not null;

Try / catch

try { /* ValueDelete body */ }
catch (ArgumentException ex) when (ex.ParamName == nameof(id))
{
    return new NullJsonResult();
}

Prevention

When it happens

Trigger: POST ValueDelete with an id absent from the DB — duplicate delete click, stale grid after a prior delete, or another admin removed the value first.

Common situations: Re-clicking delete on an already-removed value; concurrent edits to contact-form attribute values; retention cleanup removing the row.

Related errors


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