[GH-ISSUE #4523] Set as default' button overrides UserValves function settings #52310

Closed
opened 2026-05-05 13:26:45 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @zspine on GitHub (Aug 11, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/4523

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.
    open-webui-user-settings
  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.

Originally created by @zspine on GitHub (Aug 11, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/4523 # 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. ![open-webui-user-settings](https://github.com/user-attachments/assets/47871ee9-2784-479b-af0d-e127fe38d1a8) 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.
Author
Owner

@zspine commented on GitHub (Aug 11, 2024):

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)
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,
        )
<!-- gh-comment-id:2282726232 --> @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, ) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#52310