[PR #21232] [CLOSED] fix: add conditional warning log when SAFE_MODE deactivates functions #49027

Closed
opened 2026-04-30 01:21:04 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21232
Author: @Azzeo
Created: 2/7/2026
Status: Closed

Base: devHead: fix/safe-mode-logging


📝 Commits (1)

  • 62780b8 fix: add conditional warning log when SAFE_MODE deactivates functions

📊 Changes

1 file changed (+18 additions, -6 deletions)

View changed files

📝 backend/open_webui/models/functions.py (+18 -6)

📄 Description

Pull Request Checklist

Before submitting, make sure you've checked the following:

  • Target branch: Verify that the pull request targets the dev branch. Not targeting the dev branch will lead to immediate closure of the PR.
  • Description: Provide a concise description of the changes made in this pull request down below.
  • Changelog: Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
  • Documentation: If necessary, update relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs) like environment variables, the tutorials, or other documentation sources.
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Take this as an opportunity to make screenshots of the feature/fix and include it in the PR description.
  • Agentic AI Code: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review AND manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Title Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:

Changelog Entry

Description

Improved visibility when SAFE_MODE is enabled by adding a conditional warning log when functions are deactivated.

Added

  • A warning log that triggers specifically when SAFE_MODE successfully deactivates active functions.

Changed

  • Updated deactivate_all_functions in FunctionsTable to use a filtered update query. It now calculates the exact number of affected rows and only logs if changes were actually made.

Deprecated

  • N/A

Removed

  • N/A

Fixed

  • Fixed the issue where SAFE_MODE would silently disable functions without informing the administrator in the logs.

Security

  • N/A

Breaking Changes

  • N/A

Additional Information

Currently, when SAFE_MODE is enabled, the system runs deactivate_all_functions silently. This makes debugging difficult if an administrator forgets the environment variable is set.

This PR introduces a check that:

  1. Filters the update query to only target is_active=True functions.
  2. Captures the row_count of modified functions.
  3. Logs a warning only if functions were actually modified.

This ensures the logs are not spammed on repeated restarts (idempotent logging) but clearly warns the user when the action is taken.

Technical Notes:

  • Used synchronize_session=False for the bulk update to ensure performance.

Testing:
I have confirmed this works by enabling SAFE_MODE, then toggling functions on, restarting and then see the appropriate number of functions being disabled in the logs. The functions are confirmed to have been disabled.

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.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/21232 **Author:** [@Azzeo](https://github.com/Azzeo) **Created:** 2/7/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/safe-mode-logging` --- ### 📝 Commits (1) - [`62780b8`](https://github.com/open-webui/open-webui/commit/62780b81e0ff9779468575f6bab83237bad78f6e) fix: add conditional warning log when SAFE_MODE deactivates functions ### 📊 Changes **1 file changed** (+18 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/functions.py` (+18 -6) </details> ### 📄 Description # Pull Request Checklist **Before submitting, make sure you've checked the following:** * [x] **Target branch:** Verify that the pull request targets the `dev` branch. **Not targeting the `dev` branch will lead to immediate closure of the PR.** * [x] **Description:** Provide a concise description of the changes made in this pull request down below. * [x] **Changelog:** Ensure a changelog entry following the format of [[Keep a Changelog](https://keepachangelog.com/)](https://keepachangelog.com/) is added at the bottom of the PR description. * [x] **Documentation:** If necessary, update relevant documentation [[Open WebUI Docs](https://github.com/open-webui/docs)](https://github.com/open-webui/docs) like environment variables, the tutorials, or other documentation sources. * [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? * [x] **Testing:** Perform manual tests to **verify the implemented fix/feature works as intended AND does not break any other functionality**. Take this as an opportunity to **make screenshots of the feature/fix and include it in the PR description**. * [x] **Agentic AI Code:** Confirm this Pull Request is **not written by any AI Agent** or has at least **gone through additional human review AND manual testing**. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR. * [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? * [x] **Title Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: # Changelog Entry ### Description Improved visibility when `SAFE_MODE` is enabled by adding a conditional warning log when functions are deactivated. ### Added * A warning log that triggers specifically when `SAFE_MODE` successfully deactivates active functions. ### Changed * Updated `deactivate_all_functions` in `FunctionsTable` to use a filtered update query. It now calculates the exact number of affected rows and only logs if changes were actually made. ### Deprecated * N/A ### Removed * N/A ### Fixed * Fixed the issue where `SAFE_MODE` would silently disable functions without informing the administrator in the logs. ### Security * N/A ### Breaking Changes * N/A --- ### Additional Information Currently, when `SAFE_MODE` is enabled, the system runs `deactivate_all_functions` silently. This makes debugging difficult if an administrator forgets the environment variable is set. This PR introduces a check that: 1. Filters the update query to only target `is_active=True` functions. 2. Captures the `row_count` of modified functions. 3. Logs a warning **only if** functions were actually modified. This ensures the logs are not spammed on repeated restarts (idempotent logging) but clearly warns the user when the action is taken. **Technical Notes:** * Used `synchronize_session=False` for the bulk update to ensure performance. **Testing:** I have confirmed this works by enabling SAFE_MODE, then toggling functions on, restarting and then see the appropriate number of functions being disabled in the logs. The functions are confirmed to have been disabled. ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-30 01:21:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#49027