fullstackhero/dotnet-starter-kit · error · CustomException
Another category with name
Error message
Another category with name '{command.Name}' already exists. What it means
UpdateCategory checks whether any other category already uses the resulting Slug; if so it throws CustomException with 409 Conflict, using the name in the message because slug is derived from name. It enforces unique category slugs at the application level.
Solutions
- Choose a different, unique category name.
- If duplicates are legitimate, disambiguate the name (add a qualifier) so the slug differs.
- Refresh the category list to confirm the conflicting name, then decide which to keep.
- Consider surfacing slug uniqueness in the form validator before submission.
Example fix
// before
await api.updateCategory({ id, name: 'Electronics' }); // conflicts
// after
await api.updateCategory({ id, name: 'Electronics Outlet' }); // unique slug Defensive patterns
Strategy: validation
Validate before calling
const others = (await api.listCategories()).items.filter(c => c.id !== editingId);
const slug = slugify(payload.name);
if (others.some(c => c.slug === slug)) {
return formError('A category with this name already exists.');
} Try / catch
try { await api.updateCategory(payload); }
catch (e) { if (e.status === 409) formError('Name already in use — pick another'); else throw e; } Prevention
- Check name uniqueness in the form before submit
- Slugify names the same way the server does when pre-checking
- Refresh the list before renaming to catch recent duplicates
When it happens
Trigger: PUT update renaming a category to a name whose generated slug collides with another existing category's slug (excluding itself via c.Id != category.Id).
Common situations: Two categories named alike (e.g. 'Shoes (sale)' and 'Shoes sale' slug-collide); renaming a category to match an existing one; race where another user created the same name between page load and save.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- A product with name ' ' already exists.
- Another product with name
- A brand with name ' ' already exists.
- Another brand with name
- A category with name
AI-assisted analysis of fullstackhero/dotnet-starter-kit@3f2959e683 (2026-09-15).
Data as JSON: /api/errors/7f0818a453edb3ef.
Report an issue: GitHub.
Appendix: source
Thrown at src/Modules/Catalog/Modules.Catalog/Features/v1/Categories/UpdateCategory/UpdateCategoryCommandHandler.cs:59
(IEnumerable<string>?)null,
HttpStatusCode.BadRequest);
}
cursor = await dbContext.Categories
.Where(c => c.Id == cur)
.Select(c => c.ParentCategoryId)
.FirstOrDefaultAsync(cancellationToken)
.ConfigureAwait(false);
}
}
category.Update(command.Name, command.Description, command.ParentCategoryId);
bool slugTaken = await dbContext.Categories
.AnyAsync(c => c.Slug == category.Slug && c.Id != category.Id, cancellationToken)
.ConfigureAwait(false);
if (slugTaken)
{
throw new CustomException(
$"Another category with name '{command.Name}' already exists.",
(IEnumerable<string>?)null,
HttpStatusCode.Conflict);
}
await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
return category.Id;
}
}
View on GitHub (pinned to 3f2959e683)