nopSolutions/nopCommerce · error · ArgumentException

No vendor attribute value found with the specified id

Error message

No vendor attribute value found with the specified id

What it means

Thrown by VendorAttributeController.ValueDelete when GetAttributeValueByIdAsync(id) returns null. The delete action (behind MANAGE_SETTINGS permission) removes a vendor attribute value by id and logs the activity; a null lookup throws ArgumentException before DeleteAttributeValueAsync. Notably, the activity-log message uses the value's Id, so the lookup must succeed before logging.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/VendorAttributeController.cs:339

            ViewBag.RefreshPage = true;

            return View(model);
        }

        //prepare model
        model = await _vendorAttributeModelFactory.PrepareVendorAttributeValueModelAsync(model, vendorAttribute, vendorAttributeValue, 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)
    {
        //try to get a vendor attribute value with the specified id
        var value = await _vendorAttributeService.GetAttributeValueByIdAsync(id)
            ?? throw new ArgumentException("No vendor attribute value found with the specified id", nameof(id));

        await _vendorAttributeService.DeleteAttributeValueAsync(value);

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

        return new NullJsonResult();
    }

    #endregion
}

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Dismiss the error and reload the values grid; the value is already removed.
  2. Disable the delete button after the first click to prevent double-submission.
  3. For API callers, treat null as idempotent success.
  4. Wrap the action to return NullJsonResult when the value is already absent.

Example fix

// before
var value = await _vendorAttributeService.GetAttributeValueByIdAsync(id)
    ?? throw new ArgumentException("No vendor attribute value found with the specified id", nameof(id));
await _vendorAttributeService.DeleteAttributeValueAsync(value);

// after
var value = await _vendorAttributeService.GetAttributeValueByIdAsync(id);
if (value is null)
    return new NullJsonResult(); // idempotent
Defensive patterns

Strategy: validation

Validate before calling

var value = await _vendorAttributeService.GetAttributeValueByIdAsync(id);
if (value is null)
    return; // already deleted — idempotent

Try / catch

try { await controller.ValueDelete(id); }
catch (ArgumentException ex) when (ex.Message.Contains("No vendor attribute value"))
{ /* value already removed — no-op */ }

Prevention

When it happens

Trigger: Double-click on 'delete value' in the vendor-attribute-values grid; the first request succeeds and the second hits a null lookup. Concurrent deletion from another session. A programmatic delete with a stale value id.

Common situations: User rapidly clicks delete twice. Another admin or background sync removed the value between page load and the delete confirmation. The parent vendor attribute was deleted, cascading value removal, while a stale grid still shows the value.

Related errors


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