{"record":{"id":"6a609371a1353743","repo":"diegosouzapw/OmniRoute","slug":"settings-revision-conflict","errorCode":"SETTINGS_REVISION_CONFLICT","errorMessage":"Settings changed since this snapshot; refresh and retry","messagePattern":"Settings changed since this snapshot; refresh and retry","errorType":"http","errorClass":"SettingsRevisionConflictError","httpStatus":409,"severity":"error","filePath":"src/app/api/settings/route.ts","lineNumber":447,"sourceCode":"    if (body.newPassword) {\n      body.password = await hashManagementPassword(body.newPassword);\n      delete body.newPassword;\n    }\n    delete body.currentPassword;\n    delete body.expectedRevision;\n\n    // Snapshot BEFORE the write so the success row can record a real diff.\n    const beforeSnapshot = (await getSettings()) as Record<string, unknown>;\n    let settings: Awaited<ReturnType<typeof getSettings>>;\n    try {\n      settings = await updateSettings(body, { expectedRevision });\n    } catch (error) {\n      if (error instanceof SettingsRevisionConflictError) {\n        emitSettingsFailureAudit(request, actor, \"SETTINGS_REVISION_CONFLICT\", attemptedKeys);\n        return NextResponse.json(\n          {\n            error: {\n              code: \"SETTINGS_REVISION_CONFLICT\",\n              message: \"Settings changed since this snapshot; refresh and retry\",\n              currentRevision: error.currentRevision,\n            },\n          },\n          { status: 409, headers: settingsResponseHeaders(error.currentRevision) }\n        );\n      }\n      throw error;\n    }\n\n    // Sync CLIProxyAPI settings to upstream_proxy_config table\n    const cpaUrl = rawBody.cliproxyapi_url as string | undefined;\n    const cpaFallback = rawBody.cliproxyapi_fallback_enabled as boolean | undefined;\n    if (cpaUrl && typeof cpaUrl === \"string\") {\n      const urlValidation = validateProxyUrl(cpaUrl);\n      if (urlValidation.valid === false) {\n        emitSettingsFailureAudit(request, actor, \"CLIPROXY_URL_INVALID\", attemptedKeys);\n        return NextResponse.json(","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/app/api/settings/route.ts#L429-L465","documentation":"Error \"Settings changed since this snapshot; refresh and retry\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/app/api/settings/route.ts:447 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}