Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>tags/1.8.0
| @@ -9,7 +9,6 @@ import uuid | |||
| from typing import Any, Optional, cast | |||
| from flask import current_app | |||
| from flask_login import current_user | |||
| from sqlalchemy.orm.exc import ObjectDeletedError | |||
| from configs import dify_config | |||
| @@ -295,7 +294,7 @@ class IndexingRunner: | |||
| text_docs, | |||
| embedding_model_instance=embedding_model_instance, | |||
| process_rule=processing_rule.to_dict(), | |||
| tenant_id=current_user.current_tenant_id, | |||
| tenant_id=tenant_id, | |||
| doc_language=doc_language, | |||
| preview=True, | |||
| ) | |||
| @@ -7,7 +7,6 @@ from typing import TYPE_CHECKING, Any, Optional, Union | |||
| from uuid import uuid4 | |||
| import sqlalchemy as sa | |||
| from flask_login import current_user | |||
| from sqlalchemy import DateTime, orm | |||
| from core.file.constants import maybe_file_object | |||
| @@ -18,7 +17,6 @@ from core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIAB | |||
| from core.workflow.nodes.enums import NodeType | |||
| from factories.variable_factory import TypeMismatchError, build_segment_with_type | |||
| from libs.datetime_utils import naive_utc_now | |||
| from libs.helper import extract_tenant_id | |||
| from ._workflow_exc import NodeNotFoundError, WorkflowDataError | |||
| @@ -351,8 +349,8 @@ class Workflow(Base): | |||
| if self._environment_variables is None: | |||
| self._environment_variables = "{}" | |||
| # Get tenant_id from current_user (Account or EndUser) | |||
| tenant_id = extract_tenant_id(current_user) | |||
| # Use workflow.tenant_id to avoid relying on request user in background threads | |||
| tenant_id = self.tenant_id | |||
| if not tenant_id: | |||
| return [] | |||
| @@ -382,8 +380,8 @@ class Workflow(Base): | |||
| self._environment_variables = "{}" | |||
| return | |||
| # Get tenant_id from current_user (Account or EndUser) | |||
| tenant_id = extract_tenant_id(current_user) | |||
| # Use workflow.tenant_id to avoid relying on request user in background threads | |||
| tenant_id = self.tenant_id | |||
| if not tenant_id: | |||
| self._environment_variables = "{}" | |||
| @@ -13,7 +13,7 @@ dependencies = [ | |||
| "cachetools~=5.3.0", | |||
| "celery~=5.5.2", | |||
| "chardet~=5.1.0", | |||
| "flask~=3.1.0", | |||
| "flask~=3.1.2", | |||
| "flask-compress~=1.17", | |||
| "flask-cors~=6.0.0", | |||
| "flask-login~=0.6.3", | |||
| @@ -9,7 +9,6 @@ from core.file.models import File | |||
| from core.variables import FloatVariable, IntegerVariable, SecretVariable, StringVariable | |||
| from core.variables.segments import IntegerSegment, Segment | |||
| from factories.variable_factory import build_segment | |||
| from models.model import EndUser | |||
| from models.workflow import Workflow, WorkflowDraftVariable, WorkflowNodeExecutionModel, is_system_variable_editable | |||
| @@ -43,14 +42,9 @@ def test_environment_variables(): | |||
| {"name": "var4", "value": 3.14, "id": str(uuid4()), "selector": ["env", "var4"]} | |||
| ) | |||
| # Mock current_user as an EndUser | |||
| mock_user = mock.Mock(spec=EndUser) | |||
| mock_user.tenant_id = "tenant_id" | |||
| with ( | |||
| mock.patch("core.helper.encrypter.encrypt_token", return_value="encrypted_token"), | |||
| mock.patch("core.helper.encrypter.decrypt_token", return_value="secret"), | |||
| mock.patch("models.workflow.current_user", mock_user), | |||
| ): | |||
| # Set the environment_variables property of the Workflow instance | |||
| variables = [variable1, variable2, variable3, variable4] | |||
| @@ -90,14 +84,9 @@ def test_update_environment_variables(): | |||
| {"name": "var4", "value": 3.14, "id": str(uuid4()), "selector": ["env", "var4"]} | |||
| ) | |||
| # Mock current_user as an EndUser | |||
| mock_user = mock.Mock(spec=EndUser) | |||
| mock_user.tenant_id = "tenant_id" | |||
| with ( | |||
| mock.patch("core.helper.encrypter.encrypt_token", return_value="encrypted_token"), | |||
| mock.patch("core.helper.encrypter.decrypt_token", return_value="secret"), | |||
| mock.patch("models.workflow.current_user", mock_user), | |||
| ): | |||
| variables = [variable1, variable2, variable3, variable4] | |||
| @@ -136,14 +125,9 @@ def test_to_dict(): | |||
| # Create some EnvironmentVariable instances | |||
| # Mock current_user as an EndUser | |||
| mock_user = mock.Mock(spec=EndUser) | |||
| mock_user.tenant_id = "tenant_id" | |||
| with ( | |||
| mock.patch("core.helper.encrypter.encrypt_token", return_value="encrypted_token"), | |||
| mock.patch("core.helper.encrypter.decrypt_token", return_value="secret"), | |||
| mock.patch("models.workflow.current_user", mock_user), | |||
| ): | |||
| # Set the environment_variables property of the Workflow instance | |||
| workflow.environment_variables = [ | |||
| @@ -1436,7 +1436,7 @@ requires-dist = [ | |||
| { name = "cachetools", specifier = "~=5.3.0" }, | |||
| { name = "celery", specifier = "~=5.5.2" }, | |||
| { name = "chardet", specifier = "~=5.1.0" }, | |||
| { name = "flask", specifier = "~=3.1.0" }, | |||
| { name = "flask", specifier = "~=3.1.2" }, | |||
| { name = "flask-compress", specifier = "~=1.17" }, | |||
| { name = "flask-cors", specifier = "~=6.0.0" }, | |||
| { name = "flask-login", specifier = "~=0.6.3" }, | |||
| @@ -1790,7 +1790,7 @@ wheels = [ | |||
| [[package]] | |||
| name = "flask" | |||
| version = "3.1.1" | |||
| version = "3.1.2" | |||
| source = { registry = "https://pypi.org/simple" } | |||
| dependencies = [ | |||
| { name = "blinker" }, | |||
| @@ -1800,9 +1800,9 @@ dependencies = [ | |||
| { name = "markupsafe" }, | |||
| { name = "werkzeug" }, | |||
| ] | |||
| sdist = { url = "https://files.pythonhosted.org/packages/c0/de/e47735752347f4128bcf354e0da07ef311a78244eba9e3dc1d4a5ab21a98/flask-3.1.1.tar.gz", hash = "sha256:284c7b8f2f58cb737f0cf1c30fd7eaf0ccfcde196099d24ecede3fc2005aa59e", size = 753440, upload-time = "2025-05-13T15:01:17.447Z" } | |||
| sdist = { url = "https://files.pythonhosted.org/packages/dc/6d/cfe3c0fcc5e477df242b98bfe186a4c34357b4847e87ecaef04507332dab/flask-3.1.2.tar.gz", hash = "sha256:bf656c15c80190ed628ad08cdfd3aaa35beb087855e2f494910aa3774cc4fd87", size = 720160, upload-time = "2025-08-19T21:03:21.205Z" } | |||
| wheels = [ | |||
| { url = "https://files.pythonhosted.org/packages/3d/68/9d4508e893976286d2ead7f8f571314af6c2037af34853a30fd769c02e9d/flask-3.1.1-py3-none-any.whl", hash = "sha256:07aae2bb5eaf77993ef57e357491839f5fd9f4dc281593a81a9e4d79a24f295c", size = 103305, upload-time = "2025-05-13T15:01:15.591Z" }, | |||
| { url = "https://files.pythonhosted.org/packages/ec/f9/7f9263c5695f4bd0023734af91bedb2ff8209e8de6ead162f35d8dc762fd/flask-3.1.2-py3-none-any.whl", hash = "sha256:ca1d8112ec8a6158cc29ea4858963350011b5c846a414cdb7a954aa9e967d03c", size = 103308, upload-time = "2025-08-19T21:03:19.499Z" }, | |||
| ] | |||
| [[package]] | |||