{"record":{"id":"88d7b55181fb28ea","repo":"nopSolutions/nopCommerce","slug":"no-tax-category-found-with-the-specified-id","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/Plugins/Nop.Plugin.Tax.Avalara/Controllers/AvalaraTaxController.cs","lineNumber":177,"sourceCode":"\n        //save tax code type as generic attribute\n        if (!string.IsNullOrEmpty(model.TypeId) && !model.TypeId.Equals(Guid.Empty.ToString()))\n            await _genericAttributeService.SaveAttributeAsync(taxCategory, AvalaraTaxDefaults.TaxCodeTypeAttribute, model.TypeId);\n\n        return Json(new { Result = true });\n    }\n\n    [HttpPost]\n    [CheckPermission(StandardPermission.Configuration.MANAGE_TAX_SETTINGS)]\n    public override async Task<IActionResult> CategoryDelete(int id)\n    {\n        //ensure that Avalara tax provider is active\n        if (!await _taxPluginManager.IsPluginActiveAsync(AvalaraTaxDefaults.SystemName))\n            return new NullJsonResult();\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\");\n\n        //delete generic attributes \n        await _genericAttributeService.SaveAttributeAsync<string>(taxCategory, AvalaraTaxDefaults.TaxCodeDescriptionAttribute, null);\n        await _genericAttributeService.SaveAttributeAsync<string>(taxCategory, AvalaraTaxDefaults.TaxCodeTypeAttribute, null);\n\n        await _taxCategoryService.DeleteTaxCategoryAsync(taxCategory);\n\n        return new NullJsonResult();\n    }\n\n    [HttpPost, ActionName(\"Categories\")]\n    [FormValueRequired(\"importTaxCodes\")]\n    [CheckPermission(StandardPermission.Configuration.MANAGE_TAX_SETTINGS)]\n    public async Task<IActionResult> ImportTaxCodes()\n    {\n        //ensure that Avalara tax provider is active\n        if (!await _taxPluginManager.IsPluginActiveAsync(AvalaraTaxDefaults.SystemName))\n            return await Categories();","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Plugins/Nop.Plugin.Tax.Avalara/Controllers/AvalaraTaxController.cs#L159-L195","documentation":"Thrown in the CategoryDelete controller action when GetTaxCategoryByIdAsync returns null for the provided id parameter. This is an ArgumentException (not NopException), meaning it indicates a programming or request error rather than a business-rule violation. The action expects a valid tax category ID to delete Avalara-specific generic attributes from.","triggerScenarios":"An HTTP POST to the CategoryDelete action with an id that does not match any TaxCategory record in the database. This typically comes from a grid delete button in the Avalara tax categories admin UI.","commonSituations":"The tax category was already deleted by another admin session or concurrent request; stale grid data in the browser references a category that no longer exists; the ID was tampered with in the request; a previous delete failed partway through leaving inconsistent state.","solutions":["Refresh the tax categories grid in the admin UI to get current data before attempting delete","Check if the tax category still exists: SELECT * FROM TaxCategory WHERE Id = <id>","If already deleted, no action needed — the end state is correct","Add client-side confirmation and handle 404/409 responses gracefully in the UI"],"exampleFix":"// before\nvar taxCategory = await _taxCategoryService.GetTaxCategoryByIdAsync(id)\n    ?? throw new ArgumentException(\"No tax category found with the specified id\");\n\n// after — return a proper HTTP response instead of throwing\nvar taxCategory = await _taxCategoryService.GetTaxCategoryByIdAsync(id);\nif (taxCategory is null)\n    return NotFound($\"No tax category found with id {id}\");","handlingStrategy":"validation","validationCode":"// Verify tax category exists before attempting delete\nvar taxCategory = await _taxCategoryService.GetTaxCategoryByIdAsync(id);\nif (taxCategory is null)\n    return Json(new { error = \"Tax category not found — it may have already been deleted\" });","typeGuard":null,"tryCatchPattern":"// Controller action — catch ArgumentException and return user-friendly response\ntry\n{\n    await _controller.CategoryDelete(id);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"tax category\"))\n{\n    Response.StatusCode = 404;\n    return Json(new { error = \"Tax category no longer exists\" });\n}","preventionTips":["Refresh grid data before performing delete operations to avoid stale references","Return HTTP 404 instead of throwing ArgumentException for missing records","Add optimistic concurrency checks to detect concurrent modifications","Use soft-delete patterns to avoid hard-deletes that cause orphaned references"],"tags":["avalara","tax-category","crud","controller","argument-exception","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}