beeradmoore/dlss-swapper · error · Exception
dlss_presets.json is empty or invalid.
Error message
dlss_presets.json is empty or invalid.
What it means
NVAPIHelper throws this when it loads dlss_presets.json to build the DLSS preset option list, but the file's parsed content is empty or fails validation, so no preset options can be constructed. It indicates the embedded/shipped dlss_presets.json resource is missing its expected preset data or has an invalid structure.
Solutions
- Verify dlss_presets.json is present and contains a non-empty, valid presets array (validate with a JSON linter/schema check).
- Restore the original dlss_presets.json from a clean install or the repository.
- Reinstall/repair the application so the resource is correctly embedded/deployed.
- If customizing the file, match the exact schema NVAPIHelper expects before loading.
Example fix
// before (broken file)
{}
// after (valid presets file)
{ "presets": [ { "id": 1, "name": "Quality" } ] } Defensive patterns
Strategy: validation
Validate before calling
var json = File.ReadAllText(presetPath);
var data = JsonSerializer.Deserialize<DlssPresets>(json);
if (data == null || data.Presets == null || data.Presets.Count == 0)
throw new InvalidDataException($"{presetPath} is empty or has no presets."); Try / catch
try { InitDlssPresets(); }
catch (Exception ex) when (ex.Message.Contains("dlss_presets.json"))
{ Logger.Error(ex); ShowFallbackPresetList(); } Prevention
- Validate dlss_presets.json against its schema after any manual edit.
- Keep the file deployed/embedded with the app and verify it in install/upgrade scripts.
- Back up the original file before customizing presets.
- Add a startup integrity check comparing file size/hash to a known-good value.
When it happens
Trigger: Calling the NVAPIHelper initialization that builds DlssPresetOptions when dlss_presets.json exists but deserializes to null/empty or lacks the expected preset entries (the else branch after a successful file read).
Common situations: App installed from a broken/partial build where the resource wasn't embedded; the JSON was hand-edited or truncated; a version change renamed or restructured the JSON schema; deployment stripped resource files.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Could not deserialize manifest.json.
- Could not deserialize GOGCatalogResponse for url
- Could not deserialize GOGEmbedFilteredResponse for url
- Could not load GitHub release data.
- LibraryPage_ZipDidNotContainAnyDlls
AI-assisted analysis of beeradmoore/dlss-swapper@ab9b1e2d4b (2026-09-15).
Data as JSON: /api/errors/17ae5dd49d8e9a77.
Report an issue: GitHub.
Appendix: source
Thrown at src/Helpers/NVAPIHelper.cs:124
{
// Load DLSS presets
try
{
var dlssPresetsJsonPath = @"Assets\dlss_presets.json";
if (File.Exists(dlssPresetsJsonPath) == true)
{
var dlssPresetOptions = JsonSerializer.Deserialize(File.ReadAllText(dlssPresetsJsonPath), SourceGenerationContext.Default.ListPresetOption)?.Where(x => x.Used == true)?.ToList();
if (dlssPresetOptions is not null && dlssPresetOptions.Count > 0)
{
for (var i = 0; i < dlssPresetOptions.Count; ++i)
{
dlssPresetOptions[i].UpdateNameFromTranslation();
}
DlssPresetOptions = dlssPresetOptions.AsReadOnly();
}
else
{
throw new Exception("dlss_presets.json is empty or invalid.");
}
}
else
{
throw new Exception("dlss_presets.json not found.");
}
}
catch (Exception err)
{
Logger.Error(err, "Could not load dlss_presets.json, using default presets.");
DlssPresetOptions = [
new PresetOption(ResourceHelper.GetString("DLSS_Preset_Default"), 0x00000000),
new PresetOption(ResourceHelper.GetFormattedResourceTemplate("DLSS_Preset_Letter", "A"), 0x00000001),
new PresetOption(ResourceHelper.GetFormattedResourceTemplate("DLSS_Preset_Letter", "B"), 0x00000002),
new PresetOption(ResourceHelper.GetFormattedResourceTemplate("DLSS_Preset_Letter", "C"), 0x00000003),
new PresetOption(ResourceHelper.GetFormattedResourceTemplate("DLSS_Preset_Letter", "D"), 0x00000004),
new PresetOption(ResourceHelper.GetFormattedResourceTemplate("DLSS_Preset_Letter", "E"), 0x00000005),
new PresetOption(ResourceHelper.GetFormattedResourceTemplate("DLSS_Preset_Letter", "F"), 0x00000006),View on GitHub (pinned to ab9b1e2d4b)