mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 11:28:35 -05:00
[PR #18094] [CLOSED] fix: Handle OAuth decryption failures gracefully on startup #24669
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/18094
Author: @NeilMazumdar
Created: 10/7/2025
Status: ❌ Closed
Base:
dev← Head:fix/oauth-decryption-graceful-handling📝 Commits (1)
136bb1cfix: Handle OAuth decryption failures gracefully on startup📊 Changes
3 files changed (+41 additions, -8 deletions)
View changed files
📝
backend/open_webui/main.py(+18 -4)📝
backend/open_webui/routers/configs.py(+7 -0)📝
backend/open_webui/utils/oauth.py(+16 -4)📄 Description
Pull Request Checklist
Before submitting, make sure you've checked the following:
devbranch.fix:- Bug fix or error correctionChangelog Entry
Description
This PR addresses a critical issue where the application crashes on startup with
cryptography.fernet.InvalidTokenwhen OAuth credentials cannot be decrypted due toWEBUI_SECRET_KEYmismatch. This typically occurs when:WEBUI_SECRET_KEYenvironment variable changesThe fix implements graceful error handling that logs clear error messages and disables affected MCP connections while allowing the application to start successfully, preventing complete service outages.
Added
decrypt_data()functionChanged
decrypt_data()inbackend/open_webui/utils/oauth.pyto returnOptional[dict]instead of raising exceptions on decryption failuresbackend/open_webui/main.pyduring OAuth client initialization with detailed failure messagesbackend/open_webui/routers/configs.pyto handle None return values fromdecrypt_data()Deprecated
Removed
Fixed
WEBUI_SECRET_KEYcannot be decryptedSecurity
Breaking Changes
Additional Information
Root Cause:
The application stores encrypted OAuth credentials for MCP (Model Context Protocol) tool server connections in the SQLite database. When the
WEBUI_SECRET_KEYused for Fernet encryption doesn't match the key used during encryption, thedecrypt_data()function raises anInvalidTokenexception. This exception was previously unhandled at the module level inmain.py, causing the entire FastAPI application to crash during initialization.Solution Approach:
decrypt_data()to returnNoneinstead of raising exceptions when decryption failscontinueto skip failed connections rather than crashing the applicationTesting Performed:
Real-World Impact:
This fix prevents complete service outages in production environments, particularly when:
Related Issue:
Closes #18092
Additional Context:
The fix maintains the security of OAuth credentials while preventing catastrophic failures. Administrators can now:
Screenshots or Videos
N/A - Backend infrastructure fix with no UI changes
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.