when publish new workflow tool provider failed with existed name or app_id #4955

Closed
opened 2026-02-21 18:08:45 -05:00 by yindo · 5 comments
Owner

Originally created by @zalcit on GitHub (Aug 8, 2024).

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 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.

Dify version

0.6.16

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. create a workflow. then publish a workflow tool with "Tool call name" what ever.
  2. delete the workflow. then the tool will be deleted too. (Here is the key, not really deleted or soft deleted)
  3. repeat 1 step. publish with same "Tool call name".
  4. failed with "Tool with name xxx or app_id xxx already exists"

✔️ Expected Behavior

the old one tool should be deleted.
the new one should bu published sucessful

Actual Behavior

the old one tool not really be deleted.
the new one with same tool call name publish failed

Originally created by @zalcit on GitHub (Aug 8, 2024). ### 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 [search for existing issues](https://github.com/langgenius/dify/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 0.6.16 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. create a workflow. then publish a workflow tool with "Tool call name" what ever. 2. delete the workflow. then the tool will be deleted too. (Here is the key, not really deleted or soft deleted) 3. repeat 1 step. publish with same "Tool call name". 4. failed with "Tool with name xxx or app_id xxx already exists" ### ✔️ Expected Behavior the old one tool should be deleted. the new one should bu published sucessful ### ❌ Actual Behavior the old one tool not really be deleted. the new one with same tool call name publish failed
yindo added the 🌊 feat:workflow label 2026-02-21 18:08:45 -05:00
yindo closed this issue 2026-02-21 18:08:45 -05:00
Author
Owner

@zalcit commented on GitHub (Aug 8, 2024):

image

  1. the table fileds has no soft delete flag
  2. maybe other tool has same problem. maybe should check too.
@zalcit commented on GitHub (Aug 8, 2024): ![image](https://github.com/user-attachments/assets/37699dc3-1bb9-49fc-93d2-6380a119274b) 1. the table fileds has no soft delete flag 2. maybe other tool has same problem. maybe should check too.
Author
Owner

@dosubot[bot] commented on GitHub (Aug 8, 2024):

Hello @zhuqingchao! I'm here to help you with any bugs, questions, or contributions you may have. Let me know how I can assist you!

To resolve the issue where deleting a workflow tool in Dify version 0.6.16 does not fully delete the tool, causing a conflict when trying to publish a new tool with the same name, you need to ensure that the deletion process is correctly implemented both on the backend and frontend.

Backend Implementation

Ensure that the backend service responsible for managing workflow tools correctly handles the deletion. The WorkflowToolManageService class in api/services/tools/workflow_tools_manage_service.py provides a method for deleting a workflow tool:

class WorkflowToolManageService:
    @classmethod
    def delete_workflow_tool(cls, user_id: str, tenant_id: str, workflow_tool_id: str) -> dict:
        """
        Delete a workflow tool.
        :param user_id: the user id
        :param tenant_id: the tenant id
        :param workflow_tool_id: the workflow tool id
        """
        db.session.query(WorkflowToolProvider).filter(
            WorkflowToolProvider.tenant_id == tenant_id,
            WorkflowToolProvider.id == workflow_tool_id
        ).delete()

        db.session.commit()

        return {
            'result': 'success'
        }

Frontend Implementation

Ensure that the front-end components and services are correctly handling the deletion process. The following TypeScript code snippet from web/app/components/tools/provider/detail.tsx shows how to handle the deletion of a workflow tool from the front-end:

import {
  deleteWorkflowTool,
  fetchWorkflowToolDetail,
} from '@/service/tools'
import Toast from '@/app/components/base/toast'

const removeWorkflowToolProvider = async (collectionId: string, onRefreshData: () => void) => {
  await deleteWorkflowTool(collectionId)
  onRefreshData()
  Toast.notify({
    type: 'success',
    message: 'Action successful',
  })
}

// Usage example
const handleConfirmDelete = () => {
  if (deleteAction === 'workflowTool') {
    removeWorkflowToolProvider(collection.id, onRefreshData)
  }
  setShowConfirmDelete(false)
}

Caching Mechanism

There is a caching mechanism in place that might cause the deleted tool to still appear as existing when attempting to publish a new tool with the same name. The ToolParameterCache class uses Redis to cache tool parameters, and if the cache is not properly deleted, it could cause the tool to appear as still existing.

Here is the relevant code snippet from the ToolParameterCache class:

class ToolParameterCache:
    def __init__(self, 
            tenant_id: str, 
            provider: str, 
            tool_name: str, 
            cache_type: ToolParameterCacheType,
            identity_id: str
        ):
        self.cache_key = f"{cache_type.value}_secret:tenant_id:{tenant_id}:provider:{provider}:tool_name:{tool_name}:identity_id:{identity_id}"

    def delete(self) -> None:
        """
        Delete cached model provider credentials.

        :return:
        """
        redis_client.delete(self.cache_key)

Summary

By ensuring that both the backend and frontend correctly handle the deletion process, and by properly managing the cache, you can fully delete the workflow tool and avoid conflicts when publishing a new tool with the same name. The backend service should remove the tool from the database, and the frontend should correctly call this service and handle the response. Additionally, ensure that the cache is properly deleted to prevent stale data from causing conflicts [1][2][3].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 8, 2024): <!-- Greeting --> Hello @zhuqingchao! I'm here to help you with any bugs, questions, or contributions you may have. Let me know how I can assist you! <!-- Answer --> To resolve the issue where deleting a workflow tool in Dify version 0.6.16 does not fully delete the tool, causing a conflict when trying to publish a new tool with the same name, you need to ensure that the deletion process is correctly implemented both on the backend and frontend. ### Backend Implementation Ensure that the backend service responsible for managing workflow tools correctly handles the deletion. The `WorkflowToolManageService` class in `api/services/tools/workflow_tools_manage_service.py` provides a method for deleting a workflow tool: ```python class WorkflowToolManageService: @classmethod def delete_workflow_tool(cls, user_id: str, tenant_id: str, workflow_tool_id: str) -> dict: """ Delete a workflow tool. :param user_id: the user id :param tenant_id: the tenant id :param workflow_tool_id: the workflow tool id """ db.session.query(WorkflowToolProvider).filter( WorkflowToolProvider.tenant_id == tenant_id, WorkflowToolProvider.id == workflow_tool_id ).delete() db.session.commit() return { 'result': 'success' } ``` ### Frontend Implementation Ensure that the front-end components and services are correctly handling the deletion process. The following TypeScript code snippet from `web/app/components/tools/provider/detail.tsx` shows how to handle the deletion of a workflow tool from the front-end: ```tsx import { deleteWorkflowTool, fetchWorkflowToolDetail, } from '@/service/tools' import Toast from '@/app/components/base/toast' const removeWorkflowToolProvider = async (collectionId: string, onRefreshData: () => void) => { await deleteWorkflowTool(collectionId) onRefreshData() Toast.notify({ type: 'success', message: 'Action successful', }) } // Usage example const handleConfirmDelete = () => { if (deleteAction === 'workflowTool') { removeWorkflowToolProvider(collection.id, onRefreshData) } setShowConfirmDelete(false) } ``` ### Caching Mechanism There is a caching mechanism in place that might cause the deleted tool to still appear as existing when attempting to publish a new tool with the same name. The `ToolParameterCache` class uses Redis to cache tool parameters, and if the cache is not properly deleted, it could cause the tool to appear as still existing. Here is the relevant code snippet from the `ToolParameterCache` class: ```python class ToolParameterCache: def __init__(self, tenant_id: str, provider: str, tool_name: str, cache_type: ToolParameterCacheType, identity_id: str ): self.cache_key = f"{cache_type.value}_secret:tenant_id:{tenant_id}:provider:{provider}:tool_name:{tool_name}:identity_id:{identity_id}" def delete(self) -> None: """ Delete cached model provider credentials. :return: """ redis_client.delete(self.cache_key) ``` ### Summary By ensuring that both the backend and frontend correctly handle the deletion process, and by properly managing the cache, you can fully delete the workflow tool and avoid conflicts when publishing a new tool with the same name. The backend service should remove the tool from the database, and the frontend should correctly call this service and handle the response. Additionally, ensure that the cache is properly deleted to prevent stale data from causing conflicts <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/services/tools/workflow_tools_manage_service.py)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/web/app/components/tools/provider/detail.tsx)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/helper/tool_parameter_cache.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Aug 8, 2024):

I notice you are using source code to deploy, have you started the celery worker?
If don't then things happen like you described above.

@crazywoola commented on GitHub (Aug 8, 2024): I notice you are using source code to deploy, have you started the celery worker? If don't then things happen like you described above.
Author
Owner

@zalcit commented on GitHub (Aug 8, 2024):

@crazywoola
there nothing with celery. do u delete first and create with the same "Tool call name". not the name

  1. create a workflow. then publish a workflow tool with "Tool call name" what ever.
  2. delete the workflow. then the tool will be deleted too. (Here is the key, not really deleted or soft deleted)
  3. repeat 1 step. publish with same "Tool call name".
  4. failed with "Tool with name xxx or app_id xxx already exists"
    image
@zalcit commented on GitHub (Aug 8, 2024): @crazywoola there nothing with celery. do u delete first and create with the same "Tool call name". not the name 1. create a workflow. then publish a workflow tool with "Tool call name" what ever. 2. delete the workflow. then the tool will be deleted too. (Here is the key, not really deleted or soft deleted) 3. repeat 1 step. publish with same "Tool call name". 4. failed with "Tool with name xxx or app_id xxx already exists" ![image](https://github.com/user-attachments/assets/31ff18fe-e5f4-4e51-8fc2-5dc0b052033c)
Author
Owner

@zalcit commented on GitHub (Aug 8, 2024):

image
workflow_tools_manage_service.py source code

@zalcit commented on GitHub (Aug 8, 2024): ![image](https://github.com/user-attachments/assets/993302d5-daa2-4263-b9a6-ec7589398ce0) workflow_tools_manage_service.py source code
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4955