Kareadita/Kavita · warning · KavitaException
Name must be set
Error message
Name must be set
What it means
Thrown by FilterController.ValidateAndSaveFilterUpsert when the smart-filter name is null, empty, or whitespace. The calling endpoints catch KavitaException and return it as HTTP 400 BadRequest with 'Name must be set'.
Source
Thrown at Kavita.Server/Controllers/FilterController.cs:125
{
try
{
if (string.IsNullOrEmpty(dto.Name)) return BadRequest("Name is required");
var encodedString = SmartFilterHelper.Encode(dto);
await ValidateAndSaveFilterUpsert(dto.Name!, encodedString, dto.EntityType);
return Ok();
}
catch (KavitaException ex)
{
return BadRequest(ex.Message);
}
}
private async Task ValidateAndSaveFilterUpsert(string filterName, string encodedFilter, FilterEntityType entityType)
{
var user = (await unitOfWork.UserRepository.GetUserByIdAsync(UserId, AppUserIncludes.SmartFilters))!;
if (string.IsNullOrWhiteSpace(filterName)) throw new KavitaException("Name must be set");
if (Defaults.DefaultStreams.Any(s => s.Name.Equals(filterName, StringComparison.InvariantCultureIgnoreCase)))
{
// NOTE: This checks against localization keys (on-deck), so this case will almost never happen
throw new KavitaException("You cannot use the name of a system provided stream");
}
var existingFilter = user.SmartFilters.FirstOrDefault(s => s.Name.Equals(filterName, StringComparison.InvariantCultureIgnoreCase));
if (existingFilter != null)
{
// Update the filter
existingFilter.Filter = encodedFilter;
unitOfWork.AppUserSmartFilterRepository.Update(existingFilter);
}
else
{
existingFilter = new AppUserSmartFilter()
{
Name = filterName,View on GitHub (pinned to 9c3e540000)
Solutions
- Provide a non-empty, non-whitespace name in the filter upsert request.
- Validate the name client-side before enabling submit.
- If scripting the API, assert dto.Name is not null/empty before sending.
Example fix
// before
{ "name": " ", "filter": "..." }
// after
{ "name": "My Reading List", "filter": "..." } Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(dto.Name))
return BadRequest("Name must be set"); Type guard
static bool IsValidFilterName(string? name)
=> !string.IsNullOrWhiteSpace(name); Try / catch
try { await ValidateAndSaveFilterUpsert(name, enc, type); }
catch (KavitaException ex) { return BadRequest(ex.Message); } Prevention
- Disable submit until a non-empty name is entered.
- Trim and assert non-empty on the client before posting.
- Script callers should assert dto.Name is set.
When it happens
Trigger: POST to a filter upsert endpoint (create/update smart filter, annotation filter) with an empty Name in the DTO, or with whitespace only.
Common situations: Frontend submits before the name input is filled; a scripted client omits the name field; trimming turns a spaces-only name into empty.
Related errors
- {comparison} is not applicable for {fieldName}
- You cannot use the name of a system provided stream
- invalid-metadata-provider
- smart-filter-doesnt-exist
- smart-filter-already-in-use
AI-assisted analysis of Kareadita/Kavita@9c3e540000 (2026-08-13).
Data as JSON: /api/errors/21bcb2442835527a.
Report an issue: GitHub.