Originally created by @zspine on GitHub (Aug 11, 2024).
Bug Report
When using the 'Set as default' button from the main chat screen, it overrides all previously saved UserValves function settings.
Installation Method
Docker
Environment
Open WebUI Version: v0.3.12
Operating System: Ubuntu 22.04
Browser (if applicable): All
Expected Behavior:
When any action triggers the '/user/settings/update' API endpoint, it should preserve all previously stored user settings.
Actual Behavior:
Any action triggering the '/user/settings/update' API endpoint stores only the values related to 'ui' and wipes all previously saved key values for other settings.
Specifically, when the 'Set as default' button is clicked, it clears all previously saved UserValves function settings, including custom function configurations and API key values.
Click the controls button, expand the 'Valves' section, and set the first select option to 'functions'. Then, select 'OpenAI Manifold' from the functions select dropdown.
Set any value for the 'OPENAI_API_KEY' text input by clicking the custom button and pressing enter to save.
Refresh the page and verify that the 'OPENAI_API_KEY' value is retained by opening the 'Controls' section again.
Click the 'Set as default' button.
Refresh the page again and verify that the 'OPENAI_API_KEY' value has been cleared by opening the 'Controls' section again.
Following these steps should reproduce the issue. The 'Set as default' button should preserve all previously saved user settings, including custom function configurations and API key values. Instead, it currently overrides these settings, leading to data loss.
Originally created by @zspine on GitHub (Aug 11, 2024).
# Bug Report
When using the 'Set as default' button from the main chat screen, it overrides all previously saved UserValves function settings.
## Installation Method
Docker
## Environment
- **Open WebUI Version:** v0.3.12
- **Operating System:** Ubuntu 22.04
- **Browser (if applicable):** All
## Expected Behavior:
When any action triggers the '/user/settings/update' API endpoint, it should preserve all previously stored user settings.
## Actual Behavior:
Any action triggering the '/user/settings/update' API endpoint stores only the values related to 'ui' and wipes all previously saved key values for other settings.
Specifically, when the 'Set as default' button is clicked, it clears all previously saved UserValves function settings, including custom function configurations and API key values.
## Reproduction Details
**Steps to Reproduce:**
1. Navigate to the `/workspace/functions/` workspace.
2. Add the OpenAI Manifold function (https://openwebui.com/f/hub/openai_manifold/) and enable it.

3. Return to the main app page.
4. Click the controls button, expand the 'Valves' section, and set the first select option to 'functions'. Then, select 'OpenAI Manifold' from the functions select dropdown.
5. Set any value for the 'OPENAI_API_KEY' text input by clicking the custom button and pressing enter to save.
6. Refresh the page and verify that the 'OPENAI_API_KEY' value is retained by opening the 'Controls' section again.
7. Click the 'Set as default' button.
8. Refresh the page again and verify that the 'OPENAI_API_KEY' value has been cleared by opening the 'Controls' section again.
Following these steps should reproduce the issue. The 'Set as default' button should preserve all previously saved user settings, including custom function configurations and API key values. Instead, it currently overrides these settings, leading to data loss.
The issue can be temporarily resolved by using the following workaround:
# backend/apps/webui/routers/users.py@router.post("/user/settings/update",response_model=UserSettings)asyncdefupdate_user_settings_by_session_user(form_data:UserSettings,user=Depends(get_verified_user)):# Get the current user settingscurrent_user=Users.get_user_by_id(user.id)ifnotcurrent_user:raiseHTTPException(status_code=status.HTTP_400_BAD_REQUEST,detail=ERROR_MESSAGES.USER_NOT_FOUND,)# Get the current settings or initialize if Nonecurrent_settings=current_user.settings.model_dump()ifcurrent_user.settingselse{"ui":{},"functions":{"valves":{}}}# Update the settingsnew_settings=form_data.model_dump()# Update 'ui' if present in new settingsif"ui"innew_settings:current_settings["ui"].update(new_settings["ui"])# Update 'functions.valves' if present in new settingsif"functions"innew_settingsand"valves"innew_settings["functions"]:if"functions"notincurrent_settings:current_settings["functions"]={"valves":{}}current_settings["functions"]["valves"].update(new_settings["functions"]["valves"])# Update the user in the databaseupdated_user=Users.update_user_by_id(user.id,{"settings":current_settings})ifupdated_user:returnupdated_user.settingselse:raiseHTTPException(status_code=status.HTTP_400_BAD_REQUEST,detail=ERROR_MESSAGES.USER_NOT_FOUND,)
@zspine commented on GitHub (Aug 11, 2024):
The issue can be temporarily resolved by using the following workaround:
```py
# backend/apps/webui/routers/users.py
@router.post("/user/settings/update", response_model=UserSettings)
async def update_user_settings_by_session_user(
form_data: UserSettings, user=Depends(get_verified_user)
):
# Get the current user settings
current_user = Users.get_user_by_id(user.id)
if not current_user:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=ERROR_MESSAGES.USER_NOT_FOUND,
)
# Get the current settings or initialize if None
current_settings = current_user.settings.model_dump() if current_user.settings else {"ui": {},
"functions": {"valves": {}}}
# Update the settings
new_settings = form_data.model_dump()
# Update 'ui' if present in new settings
if "ui" in new_settings:
current_settings["ui"].update(new_settings["ui"])
# Update 'functions.valves' if present in new settings
if "functions" in new_settings and "valves" in new_settings["functions"]:
if "functions" not in current_settings:
current_settings["functions"] = {"valves": {}}
current_settings["functions"]["valves"].update(new_settings["functions"]["valves"])
# Update the user in the database
updated_user = Users.update_user_by_id(user.id, {"settings": current_settings})
if updated_user:
return updated_user.settings
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=ERROR_MESSAGES.USER_NOT_FOUND,
)
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @zspine on GitHub (Aug 11, 2024).
Bug Report
When using the 'Set as default' button from the main chat screen, it overrides all previously saved UserValves function settings.
Installation Method
Docker
Environment
Expected Behavior:
When any action triggers the '/user/settings/update' API endpoint, it should preserve all previously stored user settings.
Actual Behavior:
Any action triggering the '/user/settings/update' API endpoint stores only the values related to 'ui' and wipes all previously saved key values for other settings.
Specifically, when the 'Set as default' button is clicked, it clears all previously saved UserValves function settings, including custom function configurations and API key values.
Reproduction Details
Steps to Reproduce:
/workspace/functions/workspace.Following these steps should reproduce the issue. The 'Set as default' button should preserve all previously saved user settings, including custom function configurations and API key values. Instead, it currently overrides these settings, leading to data loss.
@zspine commented on GitHub (Aug 11, 2024):
The issue can be temporarily resolved by using the following workaround: