Open lichengwu opened 1 month ago
The error message "Instance '<Workflow at 0x7f7800591750>' is not persistent within this Session" indicates that the Workflow
instance is not associated with the current SQLAlchemy session when db.session.refresh()
is called. This can happen if the instance was not added to the session or if it was removed from the session before the refresh operation.
Here are a few steps you can take to resolve this issue:
Ensure the Instance is Added to the Session: Before calling db.session.refresh()
, make sure that the Workflow
instance is added to the session using db.session.add(workflow_instance)
.
Check for Session Expiry: If the session was closed or expired before the refresh operation, you might need to reopen or reattach the instance to a new session.
Verify the Instance State: Use db.session.is_modified(workflow_instance)
to check if the instance is in a state that can be refreshed. If it returns False
, the instance might not be in a persistent state.
Review Transaction Boundaries: Ensure that the session is not being prematurely committed or rolled back, which could detach the instance from the session.
By ensuring that the Workflow
instance is properly managed within the session lifecycle, you should be able to resolve this error.
To continue talking to Dosu, mention @dosu.
Self Checks
Dify version
0.9.1-fix1
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
✔️ Expected Behavior
No response
❌ Actual Behavior
Instance '<Workflow at 0x7f7800591750>' is not persistent within this Session