{"record":{"id":"637d817b534cd449","repo":"Kareadita/Kavita","slug":"generic-error-637d81","errorCode":"generic-error","errorMessage":"generic-error","messagePattern":"generic-error","errorType":"exception","errorClass":"KavitaException","httpStatus":400,"severity":"error","filePath":"Kavita.Services/SettingsService.cs","lineNumber":521,"sourceCode":"                    Secret = updateSettingsDto.OidcConfig.Secret,\n                    CustomScopes = updateSettingsDto.OidcConfig.CustomScopes,\n                };\n            }\n\n            if (updateSettingsDto.EnableFolderWatching)\n            {\n                BackgroundJob.Enqueue(() => libraryWatcher.StartWatching());\n            }\n            else\n            {\n                BackgroundJob.Enqueue(() => libraryWatcher.StopWatching());\n            }\n        }\n        catch (Exception ex)\n        {\n            logger.LogError(ex, \"There was an exception when updating server settings\");\n            await unitOfWork.RollbackAsync(ct);\n            throw new KavitaException(\"generic-error\");\n        }\n\n\n        logger.LogInformation(\"Server Settings updated\");\n\n        return updateSettingsDto;\n    }\n\n    public async Task<AuthorityValidationResult> IsValidAuthority(string authority, CancellationToken ct = default)\n    {\n        if (string.IsNullOrEmpty(authority))\n        {\n            return AuthorityValidationResult.NotApplicable;\n        }\n\n        if (!_isDevelopment && !authority.StartsWith(\"https\"))\n        {\n            return AuthorityValidationResult.MissingHttps;","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/Kareadita/Kavita/blob/9c3e5400007f8a0282f7d883f2ad5e71716e514d/Kavita.Services/SettingsService.cs#L503-L539","documentation":"Catch-all 'something went wrong' for the server-settings update pipeline. After validating individual fields, SettingsService commits the unit of work and runs post-commit side effects (Hangfire rescheduling, stats tasks, bookmark-directory move, OIDC config swap, folder-watcher restart); if any of those throws, it logs the original exception, rolls back the transaction, and rethrows KavitaException('generic-error'). SettingsController catches this KavitaException and returns HTTP 400 with 'Something went wrong, please try again'. The real cause is in the server log, not the response.","triggerScenarios":"POST /api/settings where unitOfWork.CommitAsync fails or any post-commit step throws: DB constraint/locked-file/disk-full on commit, bookmark-directory CheckWriteAccess passing but the subsequent copy/delete failing (permissions, missing source), OIDC in-memory config assignment throwing, BackgroundJob.Enqueue failing, or TaskScheduler.ScheduleTasks/CancelStatsTasks erroring.","commonSituations":"SQLite DB file locked (e.g. AV/backup touching it on Windows); disk full so commit/copy fails; bookmark directory on a read-only or unmounted volume; Hangfire storage misconfigured; folder watcher throwing on a library path; partial OIDC config that passed validation but broke runtime assignment.","solutions":["Read the server log around the timestamp for the logged original exception (message 'There was an exception when updating server settings') — the response message is intentionally generic.","Verify free disk space and write permissions on the DB, cache, bookmark, and temp directories.","Ensure the DB file is not locked by another process (AV scan, shadow copy, second Kavita instance).","Retry the save once the underlying resource is available; if it reproduces, isolate which setting triggers it by saving fields in smaller batches.","For bookmark-directory moves, confirm the target is writable and on the same volume to avoid copy failures."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// generic-error is a server fault; the real cause is in the server log.\nasync function saveSettings(dto: ServerSettings) {\n  try {\n    return await api.post('/api/settings', dto);\n  } catch (e) {\n    // 400 with translated 'Something went wrong' = transient/persistent server issue.\n    notify('Could not save settings. Check server logs, disk space, and DB access.');\n    throw e;\n  }\n}","preventionTips":["Monitor free disk space and DB file accessibility (SQLite locks on Windows).","Keep bookmark/cache/temp directories on writable, persistent volumes.","After this error, read the server log entry 'There was an exception when updating server settings' for the true stack trace before retrying.","Save large setting changes in smaller batches to isolate which field triggers the failure."],"tags":["settings","persistence","database","hangfire","generic","admin"],"backgroundTag":null,"analyzedSha":"9c3e5400007f8a0282f7d883f2ad5e71716e514d","analyzedAt":"2026-08-13T19:06:05.897Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}