-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix: Improve data consistency in update_flow function #5516
base: main
Are you sure you want to change the base?
Conversation
…d in the database during flow update 📝 (flows.py): Improve error handling and rollback database session in case of exceptions during flow update 📝 (flows.py): Refactor code to handle unique constraint errors and provide more informative error messages 📝 (utils.py): Refactor get_webhook_component_in_flow function to handle cases where flow_data may not have 'nodes' attribute
CodSpeed Performance ReportMerging #5516 will improve performances by 26.12%Comparing Summary
Benchmarks breakdown
|
…r folder buttons for improved accessibility and testing ✨ (general-bugs-move-flow-from-folder.spec.ts): add test to ensure user can move flow from one folder to another in the frontend application
…-ai/langflow into cz/fix-move-flow-folder
…l data inconsistency ♻️ (service.py): refactor with_session method to handle session commit and rollback more effectively
…-ai/langflow into cz/fix-move-flow-folder
…ption handling for better error propagation and clarity
if flow.data is None: | ||
flow.data = db_flow.data |
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.
if we are saving db_flow, why are we setting this here?
Can't we just do something like `flow.model_dump(exclude_unset=True, exclude_none=True?)
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.
this is because in some cases, the frontend needs to update parts of the flow (such as the description or name) without sending all the data to the backend. In these situations, we must retrieve the data from the database to save the changes..
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.
But the db_flow is the one being added to the database already.
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.
We are putting db_flow
data into flow
then saving db_flow
. We don't need to do that.
Again: can't we just do something like flow.model_dump(exclude_unset=True, exclude_none=True)
?
Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
if flow.data is None: | ||
flow.data = db_flow.data |
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.
But the db_flow is the one being added to the database already.
if flow.data is None: | ||
flow.data = db_flow.data |
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.
We are putting db_flow
data into flow
then saving db_flow
. We don't need to do that.
Again: can't we just do something like flow.model_dump(exclude_unset=True, exclude_none=True)
?
This pull request includes several changes to the
update_flow
function and a utility function in the backend of the Langflow API. The modifications aim to improve error handling, ensure data integrity, and enhance functionality.Improvements to
update_flow
function:flow.data
todb_flow.data
if it isNone
to ensure data consistency.db_flow
after committing the session, ensuring the updated flow is returned.except
block to handle errors more gracefully and ensure the database state is not corrupted.Enhancements to utility function:
flow_data
to prevent potential attribute errors in theget_webhook_component_in_flow
function.