Skip to content

fix: published workflow(tool) can be deleted. #17900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2025

Conversation

laipz8200
Copy link
Member

@laipz8200 laipz8200 commented Apr 11, 2025

Summary

Adds a check to prevent deletion of workflows published as tools. Introduces a test suite to ensure proper error handling for workflow deletion, including cases where workflows are drafts, in use by apps, or published as tools.

fixes #17193

Tip

Close issue syntax: Fixes #<issue number> or Resolves #<issue number>, see documentation for more details.

Screenshots

Before After
... ...

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Adds a check to prevent deletion of workflows published as tools.
Introduces a test suite to ensure proper error handling for workflow
deletion, including cases where workflows are drafts, in use by apps,
or published as tools.

Signed-off-by: -LAN- <[email protected]>
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 11, 2025
@laipz8200 laipz8200 changed the title fix: published workflow (tool) can be deleted. fix: published workflow(tool) can be deleted. Apr 11, 2025
@dosubot dosubot bot added the 🐞 bug Something isn't working label Apr 11, 2025
@laipz8200 laipz8200 requested a review from Copilot April 11, 2025 11:28
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

api/services/workflow_service.py:519

  • [nitpick] Consider introducing a dedicated exception (e.g., WorkflowPublishedToolDeletionError) for workflows published as tools to improve clarity in error handling instead of reusing WorkflowInUseError.
if workflow.tool_published:

api/test_workflow_deletion.py:114

  • [nitpick] Consider using an 'in' assertion instead of strict equality for the error message to allow for potential additional context in the exception message.
assert str(excinfo.value) == "Cannot delete workflow that is published as a tool"

Enhances test reliability by using substring assertion for error
messages, ensuring that variations in exception details do not
cause test failures.

Signed-off-by: -LAN- <[email protected]>
@laipz8200 laipz8200 requested a review from Copilot April 11, 2025 11:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

api/services/workflow_service.py:521

  • [nitpick] Consider including the workflow identifier or additional context in the error message to help with troubleshooting.
raise WorkflowInUseError("Cannot delete workflow that is published as a tool")

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 11, 2025
@crazywoola crazywoola merged commit 08a693a into main Apr 11, 2025
9 checks passed
@crazywoola crazywoola deleted the fix/published-workflow-can-be-deleted branch April 11, 2025 11:39
WTW0313 pushed a commit that referenced this pull request Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The published workflow tool can be deleted.
2 participants