Microsoft Excel 365 Plugin: SharePoint Path Interpretation Bug #816

Closed
opened 2026-02-16 10:20:36 -05:00 by yindo · 3 comments
Owner

Originally created by @ytnobody on GitHub (Nov 18, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues Dify issues & Dify Official Plugins, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.9.2

Plugin version

0.1.1

Cloud or Self Hosted

Cloud

Steps to reproduce

  1. Setup Phase:

    • Set up Azure AD with Microsoft 365 tenant
    • Configure the Dify Microsoft Excel 365 plugin
    • Grant the plugin "Sites.Selected" permission in Azure AD
    • Obtain a valid access token through OAuth authentication
  2. Configure SharePoint Access:

    • Navigate to the plugin configuration page
    • Enter your SharePoint site URL
    • Connect to a specific SharePoint site with Sites.Selected permission
  3. Trigger the Bug:

    • Use the "List All Files" tool with the following parameters:
      • site_id: Your SharePoint site ID
      • folder_path: "id:[FOLDER_ID]" (any folder ID from SharePoint)
      • file_type_filter: "all"
      • max_results: 50
  4. Observe the Error:

    • The tool will execute but return:
      HTTP 400 Invalid request
      
    • No files are listed
    • The request fails despite valid authentication
  5. Verify the Bug with Different Paths:

    • Retry with different folder ID formats:
      • Format: "id:[ID_WITH_SPECIAL_CHAR]"
      • Format: "Shared Documents" (folder names with spaces)
    • All will fail with 400 error

Expected Behavior (After Fix):

  • The tool should successfully retrieve the file list
  • Return: HTTP 200 OK with file list
  • Support both id: format and regular path names

Additional information

May be fixed with below.

File: tools/microsoft_excel_365/tools/list_all_files.py

 from collections.abc import Generator
 from typing import Any
+import urllib.parse
 
 import requests
 from dify_plugin import Tool
 from dify_plugin.entities.tool import ToolInvokeMessage
 
 
 class ListAllFilesTool(Tool):
     """List all files in OneDrive to help find Excel workbooks"""
 
     def _invoke(
         self, tool_parameters: dict[str, Any]
     ) -> Generator[ToolInvokeMessage, None, None]:
         """
         List all files in OneDrive with optional filtering.
         """
         # Get credentials
         access_token = self.runtime.credentials.get("access_token")
         if not access_token:
             yield self.create_text_message(
                 "Access token is missing. Please authenticate first."
             )
             return
 
         # Extract parameters
         folder_path = tool_parameters.get("folder_path", "root")
         file_type_filter = tool_parameters.get("file_type", "all")
         max_results = tool_parameters.get("max_results", 50)
         site_id = tool_parameters.get("site_id")
 
         headers = {
             "Authorization": f"Bearer {access_token}",
             "Accept": "application/json",
         }
 
         try:
             # Determine base drive URL (personal or SharePoint site drive)
             base_drive = (
                 f"https://graph.microsoft.com/v1.0/sites/{site_id}/drive"
                 if site_id
                 else "https://graph.microsoft.com/v1.0/me/drive"
             )
 
             # Build the API URL based on folder path
             if folder_path == "root":
                 url = f"{base_drive}/root/children"
             elif folder_path == "recent":
                 url = f"{base_drive}/recent"
             elif folder_path.startswith("id:"):
                 # If folder_path starts with "id:", treat it as a folder ID
+                # Extract the item ID and properly URL-encode it
                 folder_id = folder_path[3:]
+                # URL-encode the folder_id to handle special characters
+                encoded_folder_id = urllib.parse.quote(folder_id, safe='')
-                url = f"{base_drive}/items/{folder_id}/children"
+                url = f"{base_drive}/items/{encoded_folder_id}/children"
             else:
                 # Try to navigate by path
-                url = f"{base_drive}/root:/{folder_path}:/children"
+                # URL-encode the path to handle special characters
+                encoded_path = urllib.parse.quote(folder_path, safe='/')
+                url = f"{base_drive}/root:/{encoded_path}:/children"

✔️ Error log

input

{
  "file_type": "all",
  "folder_path": "id:b!xxxxxx...",
  "max_results": "50",
  "site_id": "XXXXXXSITENAME.sharepoint.com,XXXXXXUUID"
}

output

{
  "files": [],
  "json": [
    {
      "data": []
    }
  ],
  "text": "Failed to list files: 400 - {\"error\":{\"code\":\"invalidRequest\",\"message\":\"Invalid request\"}}"
}
Originally created by @ytnobody on GitHub (Nov 18, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.9.2 ### Plugin version 0.1.1 ### Cloud or Self Hosted Cloud ### Steps to reproduce 1. **Setup Phase:** - Set up Azure AD with Microsoft 365 tenant - Configure the Dify Microsoft Excel 365 plugin - Grant the plugin "Sites.Selected" permission in Azure AD - Obtain a valid access token through OAuth authentication 2. **Configure SharePoint Access:** - Navigate to the plugin configuration page - Enter your SharePoint site URL - Connect to a specific SharePoint site with Sites.Selected permission 3. **Trigger the Bug:** - Use the "List All Files" tool with the following parameters: - `site_id`: Your SharePoint site ID - `folder_path`: `"id:[FOLDER_ID]"` (any folder ID from SharePoint) - `file_type_filter`: `"all"` - `max_results`: `50` 4. **Observe the Error:** - The tool will execute but return: ``` HTTP 400 Invalid request ``` - No files are listed - The request fails despite valid authentication 5. **Verify the Bug with Different Paths:** - Retry with different folder ID formats: - Format: `"id:[ID_WITH_SPECIAL_CHAR]"` - Format: `"Shared Documents"` (folder names with spaces) - All will fail with 400 error **Expected Behavior (After Fix):** - The tool should successfully retrieve the file list - Return: `HTTP 200 OK` with file list - Support both `id:` format and regular path names ## Additional information May be fixed with below. **File:** `tools/microsoft_excel_365/tools/list_all_files.py` ```diff from collections.abc import Generator from typing import Any +import urllib.parse import requests from dify_plugin import Tool from dify_plugin.entities.tool import ToolInvokeMessage class ListAllFilesTool(Tool): """List all files in OneDrive to help find Excel workbooks""" def _invoke( self, tool_parameters: dict[str, Any] ) -> Generator[ToolInvokeMessage, None, None]: """ List all files in OneDrive with optional filtering. """ # Get credentials access_token = self.runtime.credentials.get("access_token") if not access_token: yield self.create_text_message( "Access token is missing. Please authenticate first." ) return # Extract parameters folder_path = tool_parameters.get("folder_path", "root") file_type_filter = tool_parameters.get("file_type", "all") max_results = tool_parameters.get("max_results", 50) site_id = tool_parameters.get("site_id") headers = { "Authorization": f"Bearer {access_token}", "Accept": "application/json", } try: # Determine base drive URL (personal or SharePoint site drive) base_drive = ( f"https://graph.microsoft.com/v1.0/sites/{site_id}/drive" if site_id else "https://graph.microsoft.com/v1.0/me/drive" ) # Build the API URL based on folder path if folder_path == "root": url = f"{base_drive}/root/children" elif folder_path == "recent": url = f"{base_drive}/recent" elif folder_path.startswith("id:"): # If folder_path starts with "id:", treat it as a folder ID + # Extract the item ID and properly URL-encode it folder_id = folder_path[3:] + # URL-encode the folder_id to handle special characters + encoded_folder_id = urllib.parse.quote(folder_id, safe='') - url = f"{base_drive}/items/{folder_id}/children" + url = f"{base_drive}/items/{encoded_folder_id}/children" else: # Try to navigate by path - url = f"{base_drive}/root:/{folder_path}:/children" + # URL-encode the path to handle special characters + encoded_path = urllib.parse.quote(folder_path, safe='/') + url = f"{base_drive}/root:/{encoded_path}:/children" ``` ### ✔️ Error log input ```json { "file_type": "all", "folder_path": "id:b!xxxxxx...", "max_results": "50", "site_id": "XXXXXXSITENAME.sharepoint.com,XXXXXXUUID" } ``` output ```json { "files": [], "json": [ { "data": [] } ], "text": "Failed to list files: 400 - {\"error\":{\"code\":\"invalidRequest\",\"message\":\"Invalid request\"}}" } ```
yindo added the bug label 2026-02-16 10:20:36 -05:00
yindo closed this issue 2026-02-16 10:20:36 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 5, 2025):

Hi, @ytnobody. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported a bug in the Microsoft Excel 365 plugin (v0.1.1) for Dify (v1.9.2) where the "List All Files" tool returns an HTTP 400 error.
  • The error occurs when using SharePoint folder paths formatted as "id:[FOLDER_ID]", especially if the folder ID contains special characters or spaces.
  • Authentication and permissions are confirmed to be valid.
  • The expected behavior is for the tool to list files correctly from the specified SharePoint folder.
  • No further comments or updates have been provided since the initial report.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of the dify-official-plugins repository by commenting here.
  • If I do not hear back within 5 days, I will automatically close this issue.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Dec 5, 2025): Hi, @ytnobody. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported a bug in the Microsoft Excel 365 plugin (v0.1.1) for Dify (v1.9.2) where the "List All Files" tool returns an HTTP 400 error. - The error occurs when using SharePoint folder paths formatted as "id:[FOLDER_ID]", especially if the folder ID contains special characters or spaces. - Authentication and permissions are confirmed to be valid. - The expected behavior is for the tool to list files correctly from the specified SharePoint folder. - No further comments or updates have been provided since the initial report. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of the dify-official-plugins repository by commenting here. - If I do not hear back within 5 days, I will automatically close this issue. Thank you for your understanding and contribution!
Author
Owner

@ytnobody commented on GitHub (Dec 7, 2025):

Please let me know if this issue is still relevant with the latest version of the dify-official-plugins repository by commenting here.

Yes, still relevant in latest version of the Microsoft Excel 365 Plugin.

@ytnobody commented on GitHub (Dec 7, 2025): > Please let me know if this issue is still relevant with the latest version of the dify-official-plugins repository by commenting here. Yes, still relevant in latest version of the Microsoft Excel 365 Plugin.
Author
Owner

@dosubot[bot] commented on GitHub (Dec 7, 2025):

@crazywoola The user reports that the HTTP 400 error with the "List All Files" tool in the Microsoft Excel 365 plugin is still occurring in the latest version. Could you please assist with this issue?

@dosubot[bot] commented on GitHub (Dec 7, 2025): @crazywoola The user reports that the HTTP 400 error with the "List All Files" tool in the Microsoft Excel 365 plugin is still occurring in the latest version. Could you please assist with this issue?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#816