[PR #24290] Flask 3.1.2 upgrade fix by Avoids using current_user in background thread #30572

Closed
opened 2026-02-21 20:47:48 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/24290

State: closed
Merged: Yes


Summary

I found new Flask 3.1.2 not working in some Chatflow DSL app and GPT 5 high propose the fix.

Tested manually in below chatflow:

image

Why this fixes it

workflow.tenant_id is always available and correct for encryption/decryption. It avoids touching current_user.current_tenant_id, which was the detached model access in the worker thread.

Status

  • Implemented the change in api/models/workflow.py; linter clean.
  • Cancelling the idea to “reload user in worker” since using workflow.tenant_id is safer and simpler.
  • Fixed DetachedInstanceError by switching env var tenant resolution to workflow.tenant_id in models/workflow.py.
  • Avoids using current_user in background thread; lints pass.
**Original Pull Request:** https://github.com/langgenius/dify/pull/24290 **State:** closed **Merged:** Yes --- # Summary I found new [Flask 3.1.2](https://flask.palletsprojects.com/en/stable/changes/#version-3-1-2) not working in some Chatflow DSL app and GPT 5 high propose the fix. Tested manually in below chatflow: <img width="672" height="779" alt="image" src="https://github.com/user-attachments/assets/cea94fee-a36f-4b3b-9c26-a887cd95e8ed" /> ### Why this fixes it workflow.tenant_id is always available and correct for encryption/decryption. It avoids touching current_user.current_tenant_id, which was the detached model access in the worker thread. ### Status * Implemented the change in api/models/workflow.py; linter clean. * Cancelling the idea to “reload user in worker” since using workflow.tenant_id is safer and simpler. * Fixed DetachedInstanceError by switching env var tenant resolution to workflow.tenant_id in models/workflow.py. * Avoids using current_user in background thread; lints pass.
yindo added the pull-request label 2026-02-21 20:47:48 -05:00
yindo closed this issue 2026-02-21 20:47:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30572