Closed AkisAya closed 2 days ago
The issue you're experiencing with the GitLab tool in the Dify self-hosted version, where file URLs are not correctly encoded, resulting in an empty result and a "file not found" error, is likely due to incorrect URL encoding of the file paths. In the fetch_files
method, while the repository identifier is URL encoded, the file paths (item_path
) are not encoded when constructing the file_url
. This can lead to issues if the file paths contain special characters that need to be URL encoded.
To fix this, ensure that item_path
is URL encoded when constructing the file_url
. Here is the relevant part of the code with the necessary change:
import urllib.parse
# ...
if is_repository:
file_url = (
f"{domain}/api/v4/projects/{encoded_identifier}/repository/files"
f"/{urllib.parse.quote(item_path, safe='')}/raw?ref={branch}"
)
else:
file_url = (
f"{domain}/api/v4/projects/{project_id}/repository/files/"
f"{urllib.parse.quote(item_path, safe='')}/raw?ref={branch}"
)
By URL encoding item_path
, you ensure that any special characters in the file path are correctly handled, which should resolve the "file not found" issue [1].
To continue talking to Dosu, mention @dosu.
Self Checks
Dify version
main
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
use gitlab tool in a workflow input a path check result
✔️ Expected Behavior
return files and it's content
❌ Actual Behavior
emtpy result and backend server report file not found