-
Notifications
You must be signed in to change notification settings - Fork 19.1k
fix: validate first then save to db #30107
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @fatelei, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where invalid workflow tool configurations could be inadvertently saved to the database due to validation occurring after the database commit. The changes refactor the tool creation and loading mechanisms to enforce upfront validation, ensuring data integrity and preventing database pollution. Additionally, the update expands the types of default values supported for plugin parameters, allowing for more flexible and complex configurations, especially for file-related inputs. These improvements collectively enhance the robustness and reliability of workflow tool management. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
bad742d to
7f6bc69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses two important issues. First, it corrects the validation order in create_workflow_tool to ensure that a WorkflowToolProvider is validated before being saved to the database, preventing database pollution with invalid entries. This is accompanied by a new test case to verify this behavior. Second, it expands the allowed types for PluginParameter.default to include list and dict, fixing a Pydantic validation error for FILE and FILES parameter types.
The changes are logical and well-supported by new tests. However, I've found a critical regression in workflow_as_tool/provider.py where the provider_id is incorrectly hardcoded, which could affect operations on existing tools. I've also suggested uncommenting an assertion in a test file to ensure the fix for the database pollution issue is properly verified. Please address these points.
I am having trouble creating individual review comments. Click here to see my feedback.
api/core/tools/workflow_as_tool/provider.py (70)
The change from provider_id=provider.id or "" to provider_id="" is incorrect. While this works for validating a new, unsaved WorkflowToolProvider (where id would be None), it breaks the logic for existing providers that are loaded from the database, as their ID will be lost. This will cause issues in downstream logic that relies on provider_id, such as in ToolLabelManager.update_tool_labels.
The fix is to use the ID from the db_provider object, which will be present for existing providers and None for new ones.
provider_id=db_provider.id or "",
api/tests/test_containers_integration_tests/services/tools/test_workflow_tools_manage_service.py (994)
The test test_create_workflow_tool_db_commit_before_validation is designed to verify that a failed validation does not leave a record in the database. The logic change in workflow_tools_manage_service.py implements this fix. Therefore, this assertion should be uncommented to ensure the test correctly verifies the fix.
assert tool_count == 0 # Expected after fix
Important
Fixes #<issue number>.Summary
fix #30030
validate first then save to db
Screenshots
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods