{"record":{"id":"72740449a1e35af8","repo":"nopSolutions/nopCommerce","slug":"no-tax-category-found-with-the-specified-id-727404","errorCode":null,"errorMessage":"No tax category found with the specified id","messagePattern":"No tax category found with the specified id","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Presentation/Nop.Web/Areas/Admin/Controllers/TaxController.cs","lineNumber":148,"sourceCode":"    public virtual async Task<IActionResult> CategoryAdd(TaxCategoryModel model)\n    {\n        if (!ModelState.IsValid)\n            return ErrorJson(ModelState.SerializeErrors());\n\n        var taxCategory = new TaxCategory();\n        taxCategory = model.ToEntity(taxCategory);\n        await _taxCategoryService.InsertTaxCategoryAsync(taxCategory);\n\n        return Json(new { Result = true });\n    }\n\n    [HttpPost]\n    [CheckPermission(StandardPermission.Configuration.MANAGE_TAX_SETTINGS)]\n    public virtual async Task<IActionResult> CategoryDelete(int id)\n    {\n        //try to get a tax category with the specified id\n        var taxCategory = await _taxCategoryService.GetTaxCategoryByIdAsync(id)\n            ?? throw new ArgumentException(\"No tax category found with the specified id\", nameof(id));\n\n        await _taxCategoryService.DeleteTaxCategoryAsync(taxCategory);\n\n        return new NullJsonResult();\n    }\n\n    #endregion\n\n    #endregion\n}","sourceCodeStart":130,"sourceCodeEnd":158,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Controllers/TaxController.cs#L130-L158","documentation":"Thrown by TaxController.CategoryDelete when ITaxCategoryService.GetTaxCategoryByIdAsync(id) returns null. The action (behind MANAGE_TAX_SETTINGS permission) deletes a tax category by id and aborts with ArgumentException if the lookup fails, before DeleteTaxCategoryAsync is called.","triggerScenarios":"Deleting a tax category that was already removed by another request or session. A double-click on the delete control. A programmatic delete with an id referencing a row removed during a tax-config migration or reset.","commonSituations":"Two admin tabs both viewing the tax categories list; one deletes a category and the other attempts the same delete. A plugin or upgrade merges/renumbers tax categories, invalidating the cached grid id. The default tax category was deleted and the id is stale.","solutions":["Refresh the tax categories list; the category is already deleted and no further action is required.","Guard the UI with a single-click delete and post-delete grid refresh.","For API callers, treat a null lookup as idempotent success (already deleted) rather than an error.","Wrap the action to return a benign NullJsonResult when the category is absent."],"exampleFix":"// before\nvar taxCategory = await _taxCategoryService.GetTaxCategoryByIdAsync(id)\n    ?? throw new ArgumentException(\"No tax category found with the specified id\", nameof(id));\nawait _taxCategoryService.DeleteTaxCategoryAsync(taxCategory);\n\n// after\nvar taxCategory = await _taxCategoryService.GetTaxCategoryByIdAsync(id);\nif (taxCategory is null)\n    return new NullJsonResult(); // idempotent","handlingStrategy":"validation","validationCode":"var taxCategory = await _taxCategoryService.GetTaxCategoryByIdAsync(id);\nif (taxCategory is null)\n    return; // already deleted — idempotent","typeGuard":null,"tryCatchPattern":"try { await taxController.CategoryDelete(id); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"No tax category found\"))\n{ /* already removed — no-op */ }","preventionTips":["Disable the delete button after first click.","Refresh the tax categories list after deletion to reflect current state.","Treat not-found on delete as idempotent success in scripts."],"tags":["nopcommerce","admin-controller","not-found","tax","delete","argument-exception"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}