Skip to content

plugin upgrade or degrade plugin file is not exists #736

@fatelei

Description

@fatelei

Self Checks

To make sure we get to you in time, please check the following :)

  • I have searched for existing issues search for existing issues, 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."

Versions

  1. dify-plugin-daemon Version
  2. dify-api Version

Describe the bug

When a user triggers a plugin downgrade (e.g., from langgenius/openai:0.4.0 to langgenius/openai:0.3.8) through the Dify UI, the upgrade_plugin_with_marketplace method in plugin_service.py fails due to an inconsistency between two database tables in the daemon:

  1. fetch_plugin_manifest(0.3.8) is called on the daemon
    → The daemon looks up the plugin_declarations table and finds the record (this table is NOT cleaned up during upgrades)
    → Returns success ✅
  2. Since the manifest exists, the code assumes the package is already available locally
    → Skips the download_plugin_pkg + upload_pkg steps ❌
  3. upgrade_plugin(0.4.0 → 0.3.8) is called on the daemon directly
    → The daemon queries the plugins table (this record WAS deleted during the previous upgrade when refers dropped to 0)
    → Falls through to the slow path, calls manager.Install()
    → Tries to read the package file from packageBucket → file not found → ERROR ❌

Root cause: The Dify API server uses fetch_plugin_manifest to determine whether a plugin package is already available in the daemon's local storage. However, the plugin_declarations record persists even after the corresponding plugins record and the actual packageBucket file have been removed. These two checks are inconsistent, causing the API server to skip the download-and-upload step for downgrade scenarios.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions