Kareadita/Kavita · warning · KavitaException

invalid-metadata-provider

invalid-metadata-provider

Error message

invalid-metadata-provider

What it means

Thrown by LibraryController.ValidateMetadataProvider when the supplied MetadataProvider is not valid for the given LibraryType, per KavitaPlusConfiguration.MetadataProvidersForLibraryTypes (e.g. only Mangabaka for Manga, Hardcover/ComicBookRoundup for Comic). A KavitaException surfacing as HTTP 500 with 'invalid-metadata-provider'.

Source

Thrown at Kavita.Server/Controllers/LibraryController.cs:774

        library.LibraryFileTypes = dto.FileGroupTypes
            .Select(t => new LibraryFileTypeGroup() {FileTypeGroup = t, LibraryId = library.Id})
            .Distinct()
            .ToList();

        library.LibraryExcludePatterns = dto.ExcludePatterns
            .Distinct()
            .Select(t => new LibraryExcludePattern() {Pattern = t, LibraryId = library.Id})
            .ToList();

        unitOfWork.LibraryRepository.Update(library);
    }

    private static void ValidateMetadataProvider(LibraryType type, MetadataProvider provider)
    {
        if (!KavitaPlusConfiguration.MetadataProvidersForLibraryTypes.TryGetValue(type, out var validProviders) || !validProviders.Contains(provider))
        {
            throw new KavitaException("invalid-metadata-provider");
        }
    }

    /// <summary>
    /// Returns the type of the underlying library
    /// </summary>
    /// <param name="libraryId"></param>
    /// <returns></returns>
    [LibraryAccess]
    [HttpGet("type")]
    public async Task<ActionResult<LibraryType>> GetLibraryType(int libraryId)
    {
        var ct = HttpContext.RequestAborted;
        return Ok(await unitOfWork.LibraryRepository.GetLibraryTypeAsync(libraryId, ct));
    }
}

View on GitHub (pinned to 9c3e540000)

Solutions

  1. Choose a MetadataProvider that the library's LibraryType allows per MetadataProvidersForLibraryTypes.
  2. Fetch valid providers via the endpoint that returns MetadataProvidersForLibraryTypes for the type, then restrict the UI selector.
  3. Keep the client's provider list in sync with the server map (note the source comment to adjust UI when the map changes).

Example fix

// before - Hardcover not valid for Manga
ValidateMetadataProvider(LibraryType.Manga, MetadataProvider.Hardcover);

// after - Mangabaka is the allowed provider for Manga
ValidateMetadataProvider(LibraryType.Manga, MetadataProvider.Mangabaka);
Defensive patterns

Strategy: validation

Validate before calling

if (!KavitaPlusConfiguration.MetadataProvidersForLibraryTypes
        .TryGetValue(type, out var valid) || !valid.Contains(provider))
    return BadRequest("invalid-metadata-provider");

Type guard

static bool IsValidProvider(LibraryType t, MetadataProvider p)
    => KavitaPlusConfiguration.MetadataProvidersForLibraryTypes
       .TryGetValue(t, out var set) && set.Contains(p);

Try / catch

try { ValidateMetadataProvider(type, provider); }
catch (KavitaException) { return BadRequest("invalid-metadata-provider"); }

Prevention

When it happens

Trigger: A library update/create call sets a MetadataProvider not in the allowed set for that LibraryType — e.g. choosing Hardcover for a Manga library, or ComicBookRoundup for LightNovel when unsupported.

Common situations: UI offers a provider combo invalid for the library type; the MetadataProvidersForLibraryTypes map changed across versions but the client wasn't updated; misconfigured Kavita Plus provider selection.

Related errors


AI-assisted analysis of Kareadita/Kavita@9c3e540000 (2026-08-13). Data as JSON: /api/errors/9b003f0db7d1c71a. Report an issue: GitHub.