{"record":{"id":"e1590405faccc4ce","repo":"nopSolutions/nopCommerce","slug":"no-template-found-with-the-specified-id","errorCode":null,"errorMessage":"No template found with the specified id","messagePattern":"No template found with the specified id","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Presentation/Nop.Web/Areas/Admin/Controllers/TemplateController.cs","lineNumber":84,"sourceCode":"    [CheckPermission(StandardPermission.System.MANAGE_MAINTENANCE)]\n    public virtual async Task<IActionResult> CategoryTemplates(CategoryTemplateSearchModel searchModel)\n    {\n        //prepare model\n        var model = await _templateModelFactory.PrepareCategoryTemplateListModelAsync(searchModel);\n\n        return Json(model);\n    }\n\n    [HttpPost]\n    [CheckPermission(StandardPermission.System.MANAGE_MAINTENANCE)]\n    public virtual async Task<IActionResult> CategoryTemplateUpdate(CategoryTemplateModel model)\n    {\n        if (!ModelState.IsValid)\n            return ErrorJson(ModelState.SerializeErrors());\n\n        //try to get a category template with the specified id\n        var template = await _categoryTemplateService.GetCategoryTemplateByIdAsync(model.Id)\n            ?? throw new ArgumentException(\"No template found with the specified id\");\n\n        template = model.ToEntity(template);\n        await _categoryTemplateService.UpdateCategoryTemplateAsync(template);\n\n        return new NullJsonResult();\n    }\n\n    [HttpPost]\n    [CheckPermission(StandardPermission.System.MANAGE_MAINTENANCE)]\n    public virtual async Task<IActionResult> CategoryTemplateAdd(CategoryTemplateModel model)\n    {\n        if (!ModelState.IsValid)\n            return ErrorJson(ModelState.SerializeErrors());\n\n        var template = new CategoryTemplate();\n        template = model.ToEntity(template);\n        await _categoryTemplateService.InsertCategoryTemplateAsync(template);\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Controllers/TemplateController.cs#L66-L102","documentation":"Thrown by TemplateController.CategoryTemplateUpdate when ICategoryTemplateService.GetCategoryTemplateByIdAsync(model.Id) returns null. This is the update endpoint for category display templates (behind MANAGE_MAINTENANCE permission); the id comes from the posted CategoryTemplateModel. ModelState is validated first, then the template is looked up; a null result throws ArgumentException.","triggerScenarios":"Submitting a category-template edit form for a template that was deleted between the edit page load and the save. Posting a model with a stale or fabricated Id. Concurrent deletion by another maintenance session.","commonSituations":"An admin opens a category template for editing, leaves it idle, and another session deletes that template before the first saves. A maintenance/cleanup operation removed orphaned templates during a version upgrade.","solutions":["Return to the category templates list; if the template is gone, it was deleted externally and the edit is no longer valid.","Recreate the template if it was removed in error, then edit it again.","For programmatic updates, confirm the template exists before posting the update model.","Catch ArgumentException and return a localized ErrorJson so the maintenance UI shows a message instead of a 500."],"exampleFix":"// before\nvar template = await _categoryTemplateService.GetCategoryTemplateByIdAsync(model.Id)\n    ?? throw new ArgumentException(\"No template found with the specified id\");\ntemplate = model.ToEntity(template);\n\n// after\nvar template = await _categoryTemplateService.GetCategoryTemplateByIdAsync(model.Id);\nif (template is null)\n    return ErrorJson(\"This category template no longer exists.\");\ntemplate = model.ToEntity(template);","handlingStrategy":"validation","validationCode":"var template = await _categoryTemplateService.GetCategoryTemplateByIdAsync(model.Id);\nif (template is null)\n    return ErrorJson(\"Template no longer exists.\"); // abort update","typeGuard":null,"tryCatchPattern":"try { await controller.CategoryTemplateUpdate(model); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"No template found\"))\n{ /* template deleted externally — reload list */ }","preventionTips":["Reload the edit form if it has been open for a long time before saving.","Confirm the template exists before posting the update model.","Surface a friendly 'record no longer exists' message instead of a 500."],"tags":["nopcommerce","admin-controller","not-found","template","category-template","argument-exception"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}