SubtitleEdit/subtitleedit · warning · InvalidOperationException

Not a waveform theme file.

Error message

Not a waveform theme file.

What it means

Thrown by WaveformThemesViewModel.ImportThemeAsync when JsonSerializer.DeserializeAsync<WaveformThemeDto> returns null — i.e. the picked file parsed as valid JSON but to an empty/null token (commonly an empty file, a JSON null, or a JSON array/scalar that does not map onto the DTO). The deserialiser itself did not throw, but there is no theme object to import.

Source

Thrown at src/ui/Features/Options/Settings/WaveformThemes/WaveformThemesViewModel.cs:211

        });

        if (files.Count == 0)
        {
            return;
        }

        var path = files[0].Path.LocalPath;

        try
        {
            await using var stream = File.OpenRead(path);
            var dto = await JsonSerializer.DeserializeAsync<WaveformThemeDto>(stream, new JsonSerializerOptions
            {
                PropertyNameCaseInsensitive = true,
            });
            if (dto == null)
            {
                throw new InvalidOperationException("Not a waveform theme file.");
            }

            var theme = dto.ToThemeDisplay(Path.GetFileNameWithoutExtension(path));
            Themes.Add(theme);
            SelectedTheme = theme;
        }
        catch (Exception exception)
        {
            // The user picked this file, so a failure has to be reported - silently doing
            // nothing looks identical to a successful import of an empty theme.
            await ShowFileErrorAsync(Se.Language.General.CouldNotOpenFileXErrorY, path, exception);
        }
    }

    private async Task ShowFileErrorAsync(string format, string path, Exception exception)
    {
        Se.LogError(exception, string.Format(format, path, exception.Message));

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Open the .seWaveformTheme file in a text editor and confirm it is a JSON object with Name/TextColor/etc. properties.
  2. Re-export a known-good theme from Subtitle Edit (export theme) and compare the structure.
  3. If the file is empty or `null`, delete it and export a fresh one.
  4. Ensure the file was not corrupted in transit (e.g. git LFS pointer, download truncated).

Example fix

// the file must look like:
{
  "Name": "My Theme",
  "TextColor": "#FFFFFFFF",
  "WaveformColor": "#FF004600",
  "BackgroundColor": "#FF000000"
  // ...remaining color properties
}
Defensive patterns

Strategy: validation

Validate before calling

// Read and validate the file shape before deserialising
var text = await File.ReadAllTextAsync(path);
if (string.IsNullOrWhiteSpace(text) || text.Trim() == "null")
    throw new InvalidOperationException("Not a waveform theme file.");
using var doc = JsonDocument.Parse(text);
if (doc.RootElement.ValueKind != JsonValueKind.Object)
    throw new InvalidOperationException("Not a waveform theme file.");

Type guard

static async Task<bool> IsWaveformThemeFile(string path) {
    try { using var doc = JsonDocument.Parse(await File.ReadAllTextAsync(path)); return doc.RootElement.ValueKind == JsonValueKind.Object; }
    catch { return false; } }

Try / catch

null

Prevention

When it happens

Trigger: User picks a .seWaveformTheme file via the open-file picker; the stream deserialises without error but dto == null.

Common situations: Empty file saved with the theme extension; file contains just `null` or `[]`; file is a different theme/tool's JSON whose root is not a WaveformThemeDto-shaped object; file truncated to zero bytes.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/c42229a3c4073adf. Report an issue: GitHub.