[PR #22693] [CLOSED] fix: sanitize generated plugin ids from titles #49863

Closed
opened 2026-04-30 02:15:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22693
Author: @Fu-Jie
Created: 3/15/2026
Status: Closed

Base: devHead: fix/sanitize-plugin-id-from-title


📝 Commits (1)

  • 0a1aaa7 fix: sanitize plugin ids derived from titles

📊 Changes

8 files changed (+48 additions, -6 deletions)

View changed files

demos/new_create.png (+0 -0)
demos/new_success.png (+0 -0)
demos/old_create.png (+0 -0)
demos/old_error.png (+0 -0)
📝 src/lib/components/ImportModal.svelte (+3 -2)
📝 src/lib/components/admin/Functions/FunctionEditor.svelte (+14 -2)
📝 src/lib/components/workspace/Tools/ToolkitEditor.svelte (+13 -2)
📝 src/lib/utils/index.ts (+18 -0)

📄 Description

Pull Request Checklist

  • Target branch: dev
  • Description: Sanitize ids derived from plugin titles on the frontend so titles can stay user-friendly while generated ids remain valid.
  • Changelog: Entry added below.
  • Documentation: No docs update required. This changes frontend sanitization behavior for existing create/import flows without introducing new user-facing settings or APIs.
  • Dependencies: No new dependencies.
  • Testing: Manually verified with the reproduction described below and included screenshots.
  • Agentic AI Code: This PR was prepared by an AI assistant but has been manually reviewed and tested by the user.
  • Code review: Self-reviewed.
  • Design & Architecture: This keeps the existing UX and applies a smarter default when deriving ids from titles instead of adding new settings.
  • Git Hygiene: This PR only changes the frontend id derivation flow plus screenshot assets used in this PR description.
  • Title Prefix: fix

Changelog Entry

Description

When creating Functions or Tools, the frontend previously derived ids with a very simple name.replace(/\s+/g, '_').toLowerCase() rule. Titles like xxx😄 kept unsupported characters in the generated id, so creation failed later with a misleading backend validation error.

This PR makes the frontend sanitize generated ids before submission while keeping the user-facing title unchanged.

Changed

  • Add a shared toPluginId helper for frontend-generated ids.
  • Apply the same sanitization flow when creating Functions, creating Tools, and importing plugin content.
  • Convert whitespace to underscores, strip emoji and unsupported punctuation, collapse repeated underscores, and prefix ids that would otherwise start with a digit.

Fixed

  • Creating a plugin with a title like xxx😄 now succeeds because the generated id removes the emoji before submission.
  • Other unsupported punctuation such as parentheses is also removed from generated ids instead of being sent to the backend unchanged.
  • Frontend-generated ids now better match the actual validation rules instead of surfacing an inaccurate backend error during normal creation flows.

Additional Information

Manual verification

  1. Reproduced the old behavior by creating a Tool with the title xxx😄 and confirmed the previous flow surfaced the backend error.
  2. Verified the updated frontend converts the same title into a valid id and allows creation to succeed.
  3. Spot-checked additional punctuation and confirmed unsupported characters are removed from generated ids.
  4. Verified the import flow also uses the same sanitization logic.
  5. Ran npm run build successfully on this branch.

Screenshots or Videos

Old behavior while creating a Tool with title xxx😄:

Old create

Old error

New behavior with the same title after frontend sanitization:

New create

New success

Contributor License Agreement

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/22693 **Author:** [@Fu-Jie](https://github.com/Fu-Jie) **Created:** 3/15/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/sanitize-plugin-id-from-title` --- ### 📝 Commits (1) - [`0a1aaa7`](https://github.com/open-webui/open-webui/commit/0a1aaa7b3052270073dbbb483a2fc98c568b4c93) fix: sanitize plugin ids derived from titles ### 📊 Changes **8 files changed** (+48 additions, -6 deletions) <details> <summary>View changed files</summary> ➕ `demos/new_create.png` (+0 -0) ➕ `demos/new_success.png` (+0 -0) ➕ `demos/old_create.png` (+0 -0) ➕ `demos/old_error.png` (+0 -0) 📝 `src/lib/components/ImportModal.svelte` (+3 -2) 📝 `src/lib/components/admin/Functions/FunctionEditor.svelte` (+14 -2) 📝 `src/lib/components/workspace/Tools/ToolkitEditor.svelte` (+13 -2) 📝 `src/lib/utils/index.ts` (+18 -0) </details> ### 📄 Description # Pull Request Checklist - [x] **Target branch:** `dev` - [x] **Description:** Sanitize ids derived from plugin titles on the frontend so titles can stay user-friendly while generated ids remain valid. - [x] **Changelog:** Entry added below. - [x] **Documentation:** No docs update required. This changes frontend sanitization behavior for existing create/import flows without introducing new user-facing settings or APIs. - [x] **Dependencies:** No new dependencies. - [x] **Testing:** Manually verified with the reproduction described below and included screenshots. - [x] **Agentic AI Code:** This PR was prepared by an AI assistant but has been manually reviewed and tested by the user. - [x] **Code review:** Self-reviewed. - [x] **Design & Architecture:** This keeps the existing UX and applies a smarter default when deriving ids from titles instead of adding new settings. - [x] **Git Hygiene:** This PR only changes the frontend id derivation flow plus screenshot assets used in this PR description. - [x] **Title Prefix:** `fix` # Changelog Entry ### Description When creating Functions or Tools, the frontend previously derived ids with a very simple `name.replace(/\s+/g, '_').toLowerCase()` rule. Titles like `xxx😄` kept unsupported characters in the generated id, so creation failed later with a misleading backend validation error. This PR makes the frontend sanitize generated ids before submission while keeping the user-facing title unchanged. ### Changed - Add a shared `toPluginId` helper for frontend-generated ids. - Apply the same sanitization flow when creating Functions, creating Tools, and importing plugin content. - Convert whitespace to underscores, strip emoji and unsupported punctuation, collapse repeated underscores, and prefix ids that would otherwise start with a digit. ### Fixed - Creating a plugin with a title like `xxx😄` now succeeds because the generated id removes the emoji before submission. - Other unsupported punctuation such as parentheses is also removed from generated ids instead of being sent to the backend unchanged. - Frontend-generated ids now better match the actual validation rules instead of surfacing an inaccurate backend error during normal creation flows. ### Additional Information #### Manual verification 1. Reproduced the old behavior by creating a Tool with the title `xxx😄` and confirmed the previous flow surfaced the backend error. 2. Verified the updated frontend converts the same title into a valid id and allows creation to succeed. 3. Spot-checked additional punctuation and confirmed unsupported characters are removed from generated ids. 4. Verified the import flow also uses the same sanitization logic. 5. Ran `npm run build` successfully on this branch. ### Screenshots or Videos Old behavior while creating a Tool with title `xxx😄`: ![Old create](https://raw.githubusercontent.com/Fu-Jie/open-webui/0a1aaa7b3052270073dbbb483a2fc98c568b4c93/demos/old_create.png) ![Old error](https://raw.githubusercontent.com/Fu-Jie/open-webui/0a1aaa7b3052270073dbbb483a2fc98c568b4c93/demos/old_error.png) New behavior with the same title after frontend sanitization: ![New create](https://raw.githubusercontent.com/Fu-Jie/open-webui/0a1aaa7b3052270073dbbb483a2fc98c568b4c93/demos/new_create.png) ![New success](https://raw.githubusercontent.com/Fu-Jie/open-webui/0a1aaa7b3052270073dbbb483a2fc98c568b4c93/demos/new_success.png) ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [ ] 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 02:15:14 -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#49863