nopSolutions/nopCommerce · warning · ArgumentException

No address attribute value found with the specified id

Error message

No address attribute value found with the specified id

What it means

Thrown by AddressAttributeController.ValueDelete (permission: MANAGE_SETTINGS). It fetches the address 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/AddressAttributeController.cs:351

            ViewBag.RefreshPage = true;

            return View(model);
        }

        //prepare model
        model = await _addressAttributeModelFactory.PrepareAddressAttributeValueModelAsync(model, addressAttribute, addressAttributeValue, 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 an address attribute value with the specified id
        var addressAttributeValue = await _addressAttributeService.GetAttributeValueByIdAsync(id)
            ?? throw new ArgumentException("No address attribute value found with the specified id", nameof(id));

        await _addressAttributeService.DeleteAttributeValueAsync(addressAttributeValue);

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

        return new NullJsonResult();
    }

    #endregion
}

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Refresh the value grid and only delete rows that still appear.
  2. Make ValueDelete idempotent (no-op + success when the row is gone).
  3. On the client, disable the delete button after first click and handle missing-row responses gracefully.

Example fix

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

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

Strategy: fallback

Validate before calling

// Idempotent value delete.
var value = await _addressAttributeService.GetAttributeValueByIdAsync(id);
if (value == null) return new NullJsonResult();

Type guard

static bool AttributeValueExists(AddressAttributeValue 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: double-click, stale grid after a prior delete, or a value removed by another admin.

Common situations: Concurrent edits to address attribute values; rapid repeated clicks on the delete action; retention cleanup removing the value between grid load and delete.

Related errors


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