nopSolutions/nopCommerce · error · ArgumentException

No specification attribute option found with the specified i

Error message

No specification attribute option found with the specified id

What it means

Thrown by SpecificationAttributeController.OptionDelete when GetSpecificationAttributeOptionByIdAsync(id) returns null for the given option id. The delete action (behind SPECIFICATION_ATTRIBUTES_CREATE_EDIT_DELETE permission) expects an existing option and aborts with ArgumentException before calling DeleteSpecificationAttributeOptionAsync.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/SpecificationAttributeController.cs:502

            return View(model);
        }

        //prepare model
        model = await _specificationAttributeModelFactory
            .PrepareSpecificationAttributeOptionModelAsync(model, specificationAttribute, specificationAttributeOption, true);

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

    [HttpPost]
    [CheckPermission(StandardPermission.Catalog.SPECIFICATION_ATTRIBUTES_CREATE_EDIT_DELETE)]
    public virtual async Task<IActionResult> OptionDelete(int id, int specificationAttributeId)
    {
        //try to get a specification attribute option with the specified id
        var specificationAttributeOption = await _specificationAttributeService.GetSpecificationAttributeOptionByIdAsync(id)
            ?? throw new ArgumentException("No specification attribute option found with the specified id", nameof(id));

        await _specificationAttributeService.DeleteSpecificationAttributeOptionAsync(specificationAttributeOption);

        return new NullJsonResult();
    }

    [HttpGet]
    public virtual async Task<IActionResult> GetOptionsByAttributeId(string attributeId)
    {
        //do not make any permission validation here 
        //because this method could be used on some other pages (such as product editing)
        //if (!await _permissionService.AuthorizeAsync(StandardPermission.ManageAttributes))
        //    return await AccessDeniedJsonAsync();

        //this action method gets called via an ajax request
        ArgumentException.ThrowIfNullOrEmpty(attributeId);

        var options = await _specificationAttributeService.GetSpecificationAttributeOptionsBySpecificationAttributeAsync(Convert.ToInt32(attributeId));

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Dismiss the error and reload the options grid; the option is already gone, so the delete succeeded.
  2. Prevent double-submission in the UI by disabling the delete button after the first click.
  3. For API callers, check the option existence before posting and treat a not-found as idempotent success.
  4. Wrap the action to return a benign JSON result instead of throwing when the option is already absent.

Example fix

// before
var specificationAttributeOption = await _specificationAttributeService.GetSpecificationAttributeOptionByIdAsync(id)
    ?? throw new ArgumentException("No specification attribute option found with the specified id", nameof(id));
await _specificationAttributeService.DeleteSpecificationAttributeOptionAsync(specificationAttributeOption);

// after
var specificationAttributeOption = await _specificationAttributeService.GetSpecificationAttributeOptionByIdAsync(id);
if (specificationAttributeOption is null)
    return new NullJsonResult(); // idempotent: already deleted
Defensive patterns

Strategy: validation

Validate before calling

var option = await _specificationAttributeService.GetSpecificationAttributeOptionByIdAsync(id);
if (option is null)
    return; // already deleted — idempotent

Try / catch

try { await controller.OptionDelete(id, specificationAttributeId); }
catch (ArgumentException ex) when (ex.Message.Contains("No specification attribute option"))
{ /* option already removed — no-op */ }

Prevention

When it happens

Trigger: A duplicate or double-click on the delete button for an option that was already removed by the first request. Concurrent deletion from two sessions. A direct programmatic POST with an option id that no longer exists.

Common situations: User double-clicks 'delete option' in the admin grid; the first call succeeds and the second hits a null lookup. Another admin or a background sync removed the option between page load and delete confirmation.

Related errors


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