[PR #23] [MERGED] fix & enh: fix json errors with filesystem library, add new file operation capabilities, better error handling #2

Closed
opened 2026-02-15 20:17:02 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/openapi-servers/pull/23
Author: @taylorwilsdon
Created: 4/6/2025
Status: Merged
Merged: 4/6/2025
Merged by: @tjbck

Base: mainHead: enhance_filesystem


📝 Commits (3)

  • d837001 Fix fastapi response to make compatible with open-webui tools use
  • c0bb335 Add search_content, delete_path, move_path and get_metadata routes, return available directories on 403s
  • e4f5112 Fix rest of json issues for all routes, implement SuccessResponse so that read calls are not attempted after move file operations

📊 Changes

1 file changed (+273 additions, -41 deletions)

View changed files

📝 servers/filesystem/main.py (+273 -41)

📄 Description

Summary

This PR enhances and stabilizes the Secure Filesystem API by implementing several important route improvements and error-handling enhancements.

Key Updates

New API Routes:

  • /search_content: Enables searching within file contents.
  • /delete_path: Supports file/directory deletion, requiring explicit confirmation and providing recursive deletion options.
  • /move_path: Allows safe moving or renaming of files/directories within permitted directories.
  • /get_metadata: Retrieves comprehensive metadata for specified files or directories.

Improved Response Models:

  • Introduced consistent success responses via the new SuccessResponse model.
  • Enhanced error messages with clearer, detailed contextual information.

Security and Robustness:

  • Implemented case-insensitive checks to secure path validation.
  • Clearly indicates allowed directories in responses to 403 Access Denied errors.

Code Quality Enhancements:

  • Transitioned from plaintext responses to structured JSON.
  • Improved readability, maintainability, and robustness through descriptive models and structured exception handling.

Testing & Validation

  • Verified correct functionality across all routes, including permissions and error handling.
  • Validated JSON serialization and ensured response consistency with FastAPI and client integration.

Breaking Changes

  • Transitioned from plaintext to structured JSON responses across several routes, potentially requiring client-side updates.

Related Issues

  • Enhances compatibility with Open-WebUI tools integration.
image

Bugfixes shown (json error):
image
image

Fixed:
image


🔄 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/openapi-servers/pull/23 **Author:** [@taylorwilsdon](https://github.com/taylorwilsdon) **Created:** 4/6/2025 **Status:** ✅ Merged **Merged:** 4/6/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `main` ← **Head:** `enhance_filesystem` --- ### 📝 Commits (3) - [`d837001`](https://github.com/open-webui/openapi-servers/commit/d837001b5d3016ad8a8674c1c427653d38dda90c) Fix fastapi response to make compatible with open-webui tools use - [`c0bb335`](https://github.com/open-webui/openapi-servers/commit/c0bb3350fb04c5f55701898a0eee8ec5956e0200) Add search_content, delete_path, move_path and get_metadata routes, return available directories on 403s - [`e4f5112`](https://github.com/open-webui/openapi-servers/commit/e4f51122eca85052db4ef060473a6a8a1c43fa00) Fix rest of json issues for all routes, implement SuccessResponse so that read calls are not attempted after move file operations ### 📊 Changes **1 file changed** (+273 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `servers/filesystem/main.py` (+273 -41) </details> ### 📄 Description ### Summary This PR enhances and stabilizes the Secure Filesystem API by implementing several important route improvements and error-handling enhancements. ### Key Updates #### New API Routes: - **`/search_content`**: Enables searching within file contents. - **`/delete_path`**: Supports file/directory deletion, requiring explicit confirmation and providing recursive deletion options. - **`/move_path`**: Allows safe moving or renaming of files/directories within permitted directories. - **`/get_metadata`**: Retrieves comprehensive metadata for specified files or directories. #### Improved Response Models: - Introduced consistent success responses via the new `SuccessResponse` model. - Enhanced error messages with clearer, detailed contextual information. #### Security and Robustness: - Implemented case-insensitive checks to secure path validation. - Clearly indicates allowed directories in responses to `403 Access Denied` errors. #### Code Quality Enhancements: - Transitioned from plaintext responses to structured JSON. - Improved readability, maintainability, and robustness through descriptive models and structured exception handling. ### Testing & Validation - Verified correct functionality across all routes, including permissions and error handling. - Validated JSON serialization and ensured response consistency with FastAPI and client integration. ### Breaking Changes - Transitioned from plaintext to structured JSON responses across several routes, potentially requiring client-side updates. ### Related Issues - Enhances compatibility with Open-WebUI tools integration. <img width="1601" alt="image" src="https://github.com/user-attachments/assets/11b88ca7-a777-4c08-b047-4e359f38f3a2" /> Bugfixes shown (json error): ![image](https://github.com/user-attachments/assets/02322e6e-a06f-425d-8872-4359a6b37d39) ![image](https://github.com/user-attachments/assets/67488d4e-d88b-4451-98d1-6e1b2824e9fb) Fixed: ![image](https://github.com/user-attachments/assets/14ed8d63-c3b4-48ad-9b1d-344ae5182fc3) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 20:17:02 -05:00
yindo closed this issue 2026-02-15 20:17:02 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-webui/openapi-servers#2