SubtitleEdit/subtitleedit · error · InvalidDataException
Settings file is empty or null: {path}
Error message
Settings file is empty or null: {path} What it means
Thrown by SeConvSettings.Load when the file exists and opens but `JsonSerializer.Deserialize<SeConvSettings>` returns null. With System.Text.Json this happens for an empty file, a file containing only whitespace/comments that JsonCommentHandling.Skip reduces to nothing, or content that deserializes to a null reference (e.g. the literal token `null`). InvalidDataException signals a structurally-empty input distinct from a missing file.
Source
Thrown at src/seconv/Core/SeConvSettings.cs:51
private static readonly JsonSerializerOptions JsonOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
PropertyNameCaseInsensitive = true,
ReadCommentHandling = JsonCommentHandling.Skip,
AllowTrailingCommas = true,
};
public static SeConvSettings Load(string path)
{
if (!File.Exists(path))
{
throw new FileNotFoundException($"Settings file not found: {path}", path);
}
using var stream = File.OpenRead(path);
return JsonSerializer.Deserialize<SeConvSettings>(stream, JsonOptions)
?? throw new InvalidDataException($"Settings file is empty or null: {path}");
}
/// <summary>
/// Serializes a complete settings file populated with the current libse defaults —
/// every key seconv understands, with its correct (camelCase) name and default value.
/// Backs <c>seconv dump-settings</c>, which users redirect to a file as a starting point
/// (issue #11037): it teaches the schema, so no one has to guess that the key is
/// <c>removeIfAllUppercase</c> and not the GUI's <c>IsRemoveTextUppercaseLineOn</c>.
/// <para>Built by mirroring <see cref="Configuration.Settings"/> (the same source
/// <see cref="ApplyBaseSections"/> writes back into) and a fresh <see cref="ImageExportStyle"/>,
/// so the output round-trips through <see cref="Load"/> with zero unknown keys — the dump
/// can never drift from what the loader accepts.</para>
/// </summary>
public static string DumpDefaults()
{
var s = Configuration.Settings;
var g = s.General;
var hi = s.RemoveTextForHearingImpaired;View on GitHub (pinned to 17a9f07487)
Solutions
- Regenerate the file: `seconv dump-settings > settings.json`.
- Open the file and confirm it contains a JSON object with keys.
- If editing by hand, start from the dump output so the schema is correct.
- Check the file is not zero bytes: `ls -l settings.json` / `dir settings.json`.
Example fix
# before: settings.json is 0 bytes seconv in.srt out.srt --settings=settings.json # after seconv dump-settings > settings.json seconv in.srt out.srt --settings=settings.json
Defensive patterns
Strategy: try-catch
Validate before calling
var info = new FileInfo(path);
if (!info.Exists || info.Length == 0)
throw new ArgumentException("Settings file is missing or empty: " + path); Type guard
static bool SettingsFileHasContent(string? p)
{
if (string.IsNullOrWhiteSpace(p) || !File.Exists(p)) return false;
return new FileInfo(p).Length > 0;
} Try / catch
try { var s = SeConvSettings.Load(path); }
catch (InvalidDataException ex) when (ex.Message.Contains("empty or null"))
{
// regenerate via dump-settings and retry
} Prevention
- Check file size > 0 before deserializing.
- Use `seconv dump-settings` as the canonical source of a non-empty file.
- Validate JSON well-formedness with a linter in CI.
When it happens
Trigger: Calling `SeConvSettings.Load(path)` on a zero-byte file, a file of only whitespace, or a file whose top-level JSON value is `null`.
Common situations: An interrupted `dump-settings` redirect (e.g. disk full, Ctrl-C); a manually created empty placeholder; a settings file overwritten by a failed pipeline; a `null` literal left from editing.
Related errors
- Settings file not found: {path}
- BinaryOCR database is empty: {dbPath}
- Profile '{profileName}' not found in settings. Available: {a
- Unknown time format '{timeFormat}'
- Unknown type of event #{i + 1}: '{type}'
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/cbf1390dcc76955f.
Report an issue: GitHub.