langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
50.34k stars 7.21k forks source link

When I upload a document via the API, I will get the following error message: File not found #9938

Open shengxiagit opened 4 days ago

shengxiagit commented 4 days ago

Self Checks

Dify version

0.9.2 - 0.10.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I did not capture any error logs in docker. I use aliyun-oss as file storage.

✔️ Expected Behavior

process document success

❌ Actual Behavior

I use aliyun-oss as file storage. When I upload a document via the API, I will get the following error message: File not found. But When I click the retry button it works fine.

dosubot[bot] commented 4 days ago

I found a similar closed issue regarding a "File not found" error when uploading a file in a self-hosted Dify setup using Docker. The suggested solution involves ensuring that the local storage path is correctly configured and mounted. Here are the steps you can follow:

  1. Set the STORAGE_TYPE to local:

    export STORAGE_TYPE=local
  2. Define the STORAGE_LOCAL_PATH:

    export STORAGE_LOCAL_PATH=/path/to/local/storage
  3. Mount the storage directory in your Docker setup: Ensure that the /app/api/storage directory in both containers is mounted to the same local directory. This can be done by adding the following volume configuration in your docker-compose.yml file:

    volumes:
     - /path/to/local/storage:/app/api/storage
  4. Restart your Docker containers:

    docker-compose down
    docker-compose up -d

Additionally, ensure that the storage directory has the appropriate permissions and ownership settings to allow the Docker container to read from and write to it. Another user mentioned that attaching a NAS as a PVC solved the problem, indicating that shared storage between containers is necessary [1].

To continue talking to Dosu, mention @dosu.

shengxiagit commented 4 days ago

I found a similar closed issue regarding a "File not found" error when uploading a file in a self-hosted Dify setup using Docker. The suggested solution involves ensuring that the local storage path is correctly configured and mounted. Here are the steps you can follow:

  1. Set the STORAGE_TYPE to local:
    export STORAGE_TYPE=local
  2. Define the STORAGE_LOCAL_PATH:
    export STORAGE_LOCAL_PATH=/path/to/local/storage
  3. Mount the storage directory in your Docker setup: Ensure that the /app/api/storage directory in both containers is mounted to the same local directory. This can be done by adding the following volume configuration in your docker-compose.yml file:
    volumes:
     - /path/to/local/storage:/app/api/storage
  4. Restart your Docker containers:
    docker-compose down
    docker-compose up -d

Additionally, ensure that the storage directory has the appropriate permissions and ownership settings to allow the Docker container to read from and write to it. Another user mentioned that attaching a NAS as a PVC solved the problem, indicating that shared storage between containers is necessary [1].

To continue talking to Dosu, mention @dosu.

But I am using aliyun-oss, not local. And the file has been successfully uploaded to aliyun-oss @dosu

crazywoola commented 7 hours ago

Link https://github.com/langgenius/dify/issues/10069

This one can call it but it doesn't get the file.

dosubot[bot] commented 7 hours ago

If you're using Aliyun OSS and encountering a "File not found" error despite successful uploads, consider these potential causes and solutions:

  1. Check the api/storage/privkeys File: Ensure that the api/storage/privkeys file is not deleted or missing. This file is crucial for encrypting large model keys, and its absence can lead to errors. If it's lost, you can reset the encryption keys using:

    docker exec -it docker-api-1 flask reset-encrypt-key-pair

    This command is for Docker Compose deployment. For source code startup, run it from the API directory.

  2. Verify Configuration Settings: Double-check your Aliyun OSS configuration settings in your environment variables. Ensure that all required parameters like ALIYUN_OSS_BUCKET_NAME, ALIYUN_OSS_ACCESS_KEY, ALIYUN_OSS_SECRET_KEY, ALIYUN_OSS_ENDPOINT, and ALIYUN_OSS_REGION are correctly set.

  3. Check for Consistency: Ensure that the file paths and names used in your application match those in Aliyun OSS. Any discrepancies can cause the application to not find the file even if it exists in the storage.

  4. Retry Mechanism: Since you mentioned that retrying works, there might be a timing issue or a temporary connectivity problem. Implementing a retry mechanism in your application logic might help mitigate this issue.

These steps should help address the "File not found" error when using Aliyun OSS with Dify [1][2].

To continue talking to Dosu, mention @dosu.