Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: validate conversation variable description length to prevent varchar(255) truncation error (#33038)
Novice4fb3210f9a16
diff --git a/api/controllers/common/errors.py b/api/controllers/common/errors.pyindex 252cf3549aa..31dd2fcd74f 100644--- a/api/controllers/common/errors.py+++ b/api/controllers/common/errors.py@@ -41,3 +41,13 @@ class NoFileUploadedError(BaseHTTPException):error_code = "no_file_uploaded"description = "Please upload your file."code = 400+++class NotFoundError(BaseHTTPException):+ error_code = "not_found"+ code = 404+++class InvalidArgumentError(BaseHTTPException):+ error_code = "invalid_param"+ code = 400diff --git a/api/controllers/console/app/workflow.py b/api/controllers/console/app/workflow.pyindex 5d24506f213..6a14937ffa0 100644--- a/api/controllers/console/app/workflow.py+++ b/api/controllers/console/app/workflow.py@@ -12,6 +12,7 @@ from werkzeug.exceptions import BadRequest, Forbidden, InternalServerError, NotFimport servicesfrom controllers.common.controller_schemas import DefaultBlockConfigQuery, WorkflowListQuery, WorkflowUpdatePayload+from controllers.common.errors import InvalidArgumentErrorfrom controllers.common.fields import NewAppResponse, SimpleResultResponsefrom controllers.common.schema import (register_response_schema_model,@@ -19,7 +20,11 @@ from controllers.common.schema import (register_schema_models,)from controllers.console import console_ns-from controllers.console.app.error import ConversationCompletedError, DraftWorkflowNotExist, DraftWorkflowNotSync+from controllers.console.app.error import (+ ConversationCompletedError,+ DraftWorkflowNotExist,+ DraftWorkflowNotSync,+)from controllers.console.app.wraps import get_app_modelfrom controllers.console.wraps import (account_initialization_required,@@ -56,6 +61,7 @@ from graphon.file import helpers as file_helpersfrom graphon.graph_engine.manager import GraphEngineManagerfrom graphon.model_runtime.utils.encoders import jsonable_encoderfrom graphon.variables import SecretVariable, SegmentType, VariableBase+from graphon.variables.exc import VariableErrorfrom libs import helperfrom libs.datetime_utils import naive_utc_nowfrom libs.helper import TimestampField, dump_response, to_timestamp, uuid_value@@ -452,6 +458,8 @@ class DraftWorkflowApi(Resource):)except WorkflowHashNotEqualError:raise DraftWorkflowNotSync()+ except VariableError as e:+ raise InvalidArgumentError(description=str(e))return {"result": "success",diff --git a/api/controllers/console/app/workflow_draft_variable.py b/api/controllers/console/app/workflow_draft_variable.pyindex f6bb2aa008a..8ebd65eccf2 100644--- a/api/controllers/console/app/workflow_draft_variable.py+++ b/api/controllers/console/app/workflow_draft_variable.py@@ -9,6 +9,7 @@ from flask_restx import Resource, fields, marshal, marshal_withfrom pydantic import BaseModel, Fieldfrom sqlalchemy.orm import sessionmaker+from controllers.common.errors import InvalidArgumentError, NotFoundErrorfrom controllers.common.schema import register_schema_modelsfrom controllers.console import console_nsfrom controllers.console.app.error import (@@ -21,7 +22,6 @@ from controllers.console.wraps import (setup_required,with_current_user,)-from controllers.web.error import InvalidArgumentError, NotFoundErrorfrom core.app.file_access import DatabaseFileAccessControllerfrom core.workflow.variable_prefixes import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_IDfrom extensions.ext_database import dbdiff --git a/api/controllers/console/app/workflow_run.py b/api/controllers/console/app/workflow_run.pyindex 0ae9fb63090..359daa12c20 100644--- a/api/controllers/console/app/workflow_run.py+++ b/api/controllers/console/app/workflow_run.py@@ -9,6 +9,7 @@ from sqlalchemy import selectfrom sqlalchemy.orm import sessionmakerfrom configs import dify_config+from controllers.common.errors import NotFoundErrorfrom controllers.common.schema import query_params_from_model, register_response_schema_models, register_schema_modelsfrom controllers.console import console_nsfrom controllers.console.app.wraps import get_app_model@@ -18,7 +19,6 @@ from controllers.console.wraps import (with_current_tenant_id,with_current_user,)-from controllers.web.error import NotFoundErrorfrom core.workflow.human_input_forms import load_form_tokens_by_form_id as _load_form_tokens_by_form_idfrom extensions.ext_database import dbfrom fields.base import ResponseModeldiff --git a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.pyindex 4643cfa15c0..cd326dffe9e 100644--- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py+++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py@@ -10,6 +10,7 @@ from pydantic import BaseModel, Fieldfrom sqlalchemy.orm import sessionmakerfrom werkzeug.exceptions import Forbidden+from controllers.common.errors import InvalidArgumentError, NotFoundErrorfrom controllers.common.schema import register_schema_modelsfrom controllers.console import console_nsfrom controllers.console.app.error import (@@ -23,7 +24,6 @@ from controllers.console.app.workflow_draft_variable import ()from controllers.console.datasets.wraps import get_rag_pipelinefrom controllers.console.wraps import account_initialization_required, setup_required, with_current_user-from controllers.web.error import InvalidArgumentError, NotFoundErrorfrom core.app.file_access import DatabaseFileAccessControllerfrom core.workflow.variable_prefixes import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_IDfrom extensions.ext_database import dbdiff --git a/api/controllers/console/human_input_form.py b/api/controllers/console/human_input_form.pyindex 4b34cb6d9cc..0ca9d18168e 100644--- a/api/controllers/console/human_input_form.py+++ b/api/controllers/console/human_input_form.py@@ -11,6 +11,7 @@ from flask_restx import Resourcefrom sqlalchemy import selectfrom sqlalchemy.orm import Session, sessionmaker+from controllers.common.errors import InvalidArgumentError, NotFoundErrorfrom controllers.common.human_input import HumanInputFormSubmitPayloadfrom controllers.common.schema import register_schema_modelsfrom controllers.console import console_ns@@ -21,7 +22,6 @@ from controllers.console.wraps import (with_current_tenant_id,with_current_user,)-from controllers.web.error import InvalidArgumentError, NotFoundErrorfrom core.app.apps.advanced_chat.app_generator import AdvancedChatAppGeneratorfrom core.app.apps.base_app_generator import BaseAppGeneratorfrom core.app.apps.common.workflow_response_converter import WorkflowResponseConverterdiff --git a/api/controllers/console/snippets/snippet_workflow_draft_variable.py b/api/controllers/console/snippets/snippet_workflow_draft_variable.pyindex 323fb0b3338..491a78a9b93 100644--- a/api/controllers/console/snippets/snippet_workflow_draft_variable.py+++ b/api/controllers/console/snippets/snippet_workflow_draft_variable.py@@ -18,6 +18,7 @@ from flask import Response, requestfrom flask_restx import Resource, marshal, marshal_withfrom sqlalchemy.orm import Session, sessionmaker+from controllers.common.errors import InvalidArgumentError, NotFoundErrorfrom controllers.console import console_nsfrom controllers.console.app.error import DraftWorkflowNotExistfrom controllers.console.app.workflow_draft_variable import (@@ -36,7 +37,6 @@ from controllers.console.wraps import (setup_required,with_current_user,)-from controllers.web.error import InvalidArgumentError, NotFoundErrorfrom core.app.file_access import DatabaseFileAccessControllerfrom core.workflow.variable_prefixes import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_IDfrom extensions.ext_database import dbdiff --git a/api/controllers/console/workspace/trigger_providers.py b/api/controllers/console/workspace/trigger_providers.pyindex a87633e5d00..3805d0ff372 100644--- a/api/controllers/console/workspace/trigger_providers.py+++ b/api/controllers/console/workspace/trigger_providers.py@@ -8,9 +8,9 @@ from sqlalchemy.orm import sessionmakerfrom werkzeug.exceptions import BadRequest, Forbiddenfrom configs import dify_config+from controllers.common.errors import NotFoundErrorfrom controllers.common.fields import SimpleResultResponsefrom controllers.common.schema import register_response_schema_models, register_schema_models-from controllers.web.error import NotFoundErrorfrom core.plugin.entities.plugin_daemon import CredentialTypefrom core.plugin.impl.oauth import OAuthHandlerfrom core.trigger.entities.entities import SubscriptionBuilderUpdaterdiff --git a/api/controllers/web/error.py b/api/controllers/web/error.pyindex d1f936768e4..789c0fabcc1 100644--- a/api/controllers/web/error.py+++ b/api/controllers/web/error.py@@ -121,13 +121,3 @@ class WebFormRateLimitExceededError(BaseHTTPException):error_code = "web_form_rate_limit_exceeded"description = "Too many form requests. Please try again later."code = 429---class NotFoundError(BaseHTTPException):- error_code = "not_found"- code = 404---class InvalidArgumentError(BaseHTTPException):- error_code = "invalid_param"- code = 400diff --git a/api/controllers/web/human_input_form.py b/api/controllers/web/human_input_form.pyindex 113c39d3dd3..3065d57b5dd 100644--- a/api/controllers/web/human_input_form.py+++ b/api/controllers/web/human_input_form.py@@ -15,10 +15,11 @@ from sqlalchemy.orm import sessionmakerfrom werkzeug.exceptions import Forbiddenfrom configs import dify_config+from controllers.common.errors import NotFoundErrorfrom controllers.common.human_input import HumanInputFormSubmitPayload, stringify_form_default_valuesfrom controllers.common.schema import register_schema_modelsfrom controllers.web import web_ns-from controllers.web.error import NotFoundError, WebFormRateLimitExceededError+from controllers.web.error import WebFormRateLimitExceededErrorfrom controllers.web.site import serialize_app_site_payloadfrom extensions.ext_database import dbfrom graphon.nodes.human_input.entities import FormInputConfigdiff --git a/api/controllers/web/workflow_events.py b/api/controllers/web/workflow_events.pyindex 474f9c09579..b513ade58a9 100644--- a/api/controllers/web/workflow_events.py+++ b/api/controllers/web/workflow_events.py@@ -8,8 +8,8 @@ from collections.abc import Generatorfrom flask import Response, requestfrom sqlalchemy.orm import sessionmaker+from controllers.common.errors import InvalidArgumentError, NotFoundErrorfrom controllers.web import api-from controllers.web.error import InvalidArgumentError, NotFoundErrorfrom controllers.web.wraps import WebApiResourcefrom core.app.apps.advanced_chat.app_generator import AdvancedChatAppGeneratorfrom core.app.apps.base_app_generator import BaseAppGeneratordiff --git a/api/factories/variable_factory.py b/api/factories/variable_factory.pyindex fd7acb14d3a..586430c54bc 100644--- a/api/factories/variable_factory.py+++ b/api/factories/variable_factory.py@@ -48,9 +48,18 @@ __all__ = []+_MAX_VARIABLE_DESCRIPTION_LENGTH = 255++def build_conversation_variable_from_mapping(mapping: Mapping[str, Any], /) -> VariableBase:if not mapping.get("name"):raise VariableError("missing name")+ description = mapping.get("description", "")+ if len(description) > _MAX_VARIABLE_DESCRIPTION_LENGTH:+ raise VariableError(+ f"description of variable '{mapping['name']}' is too long"+ f" (max {_MAX_VARIABLE_DESCRIPTION_LENGTH} characters)"+ )return _build_variable_from_mapping(mapping=mapping, selector=[CONVERSATION_VARIABLE_NODE_ID, mapping["name"]])diff --git a/api/models/workflow.py b/api/models/workflow.pyindex 16daafe7858..bf494ad1f4b 100644--- a/api/models/workflow.py+++ b/api/models/workflow.py@@ -1861,6 +1861,8 @@ class WorkflowDraftVariable(Base):variable.file_id = file_idvariable._set_selector(list(variable_utils.to_selector(node_id, name)))variable.node_execution_id = node_execution_id+ variable.visible = True+ variable.is_default_value = Falsereturn variable@classmethoddiff --git a/api/services/workflow_draft_variable_service.py b/api/services/workflow_draft_variable_service.pyindex d7351c5fa57..7c9bd489bda 100644--- a/api/services/workflow_draft_variable_service.py+++ b/api/services/workflow_draft_variable_service.py@@ -749,6 +749,7 @@ class _InsertionDict(TypedDict):file_id: str | Nonevisible: NotRequired[bool]editable: NotRequired[bool]+ is_default_value: NotRequired[bool]created_at: NotRequired[datetime]updated_at: NotRequired[datetime]description: NotRequired[str]@@ -778,6 +779,8 @@ def _model_to_insertion_dict(model: WorkflowDraftVariable) -> _InsertionDict:d["updated_at"] = model.updated_atif model.description is not None:d["description"] = model.description+ if model.is_default_value is not None:+ d["is_default_value"] = model.is_default_valuereturn ddiff --git a/api/tests/test_containers_integration_tests/controllers/console/workspace/test_trigger_providers.py b/api/tests/test_containers_integration_tests/controllers/console/workspace/test_trigger_providers.pyindex e155b711a74..6c74b3193b9 100644--- a/api/tests/test_containers_integration_tests/controllers/console/workspace/test_trigger_providers.py+++ b/api/tests/test_containers_integration_tests/controllers/console/workspace/test_trigger_providers.py@@ -8,6 +8,7 @@ import pytestfrom flask import Flaskfrom werkzeug.exceptions import BadRequest, Forbidden+from controllers.common.errors import NotFoundErrorfrom controllers.console.workspace.trigger_providers import (TriggerOAuthAuthorizeApi,TriggerOAuthCallbackApi,@@ -26,7 +27,6 @@ from controllers.console.workspace.trigger_providers import (TriggerSubscriptionUpdateApi,TriggerSubscriptionVerifyApi,)-from controllers.web.error import NotFoundErrorfrom core.plugin.entities.plugin_daemon import CredentialTypefrom models.account import Accountdiff --git a/api/tests/unit_tests/controllers/console/app/test_workflow.py b/api/tests/unit_tests/controllers/console/app/test_workflow.pyindex 272337d0c53..d2f7770b2fb 100644--- a/api/tests/unit_tests/controllers/console/app/test_workflow.py+++ b/api/tests/unit_tests/controllers/console/app/test_workflow.py@@ -12,6 +12,7 @@ from flask import Flaskfrom pydantic import ValidationErrorfrom werkzeug.exceptions import HTTPException, NotFound+from controllers.common.errors import InvalidArgumentErrorfrom controllers.console.app import workflow as workflow_modulefrom controllers.console.app.error import DraftWorkflowNotExist, DraftWorkflowNotSyncfrom graphon.file import File, FileTransferMethod, FileType@@ -180,6 +181,29 @@ def test_sync_draft_workflow_hash_mismatch(app: Flask, monkeypatch: pytest.Monkehandler(api, "t1", app_model=SimpleNamespace(id="app"))+def test_sync_draft_workflow_variable_validation_error(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:+ def _raise(*_args, **_kwargs):+ raise workflow_module.VariableError("description too long")++ monkeypatch.setattr(workflow_module.variable_factory, "build_conversation_variable_from_mapping", _raise)+ monkeypatch.setattr(+ workflow_module, "WorkflowService", lambda: SimpleNamespace(sync_draft_workflow=lambda **_kwargs: None)+ )++ api = workflow_module.DraftWorkflowApi()+ handler = inspect.unwrap(api.post)++ with app.test_request_context(+ "/apps/app/workflows/draft",+ method="POST",+ json={"graph": {}, "features": {}, "hash": "h", "conversation_variables": [{"name": "topic"}]},+ ):+ with pytest.raises(InvalidArgumentError) as exc:+ handler(api, "t1", app_model=SimpleNamespace(id="app"))++ assert exc.value.description == "description too long"++def test_restore_published_workflow_to_draft_success(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:workflow = SimpleNamespace(unique_hash="restored-hash",diff --git a/api/tests/unit_tests/controllers/console/app/test_workflow_pause_details_api.py b/api/tests/unit_tests/controllers/console/app/test_workflow_pause_details_api.pyindex aa06aeabc85..4981971bc1b 100644--- a/api/tests/unit_tests/controllers/console/app/test_workflow_pause_details_api.py+++ b/api/tests/unit_tests/controllers/console/app/test_workflow_pause_details_api.py@@ -8,8 +8,8 @@ from unittest.mock import Mockimport pytestfrom flask import Flask+from controllers.common.errors import NotFoundErrorfrom controllers.console.app import workflow_run as workflow_run_module-from controllers.web.error import NotFoundErrorfrom graphon.entities.pause_reason import HumanInputRequiredfrom graphon.enums import WorkflowExecutionStatusfrom graphon.nodes.human_input.entities import ParagraphInputConfig, UserActionConfigdiff --git a/api/tests/unit_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_draft_variable.py b/api/tests/unit_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_draft_variable.pyindex 9b491d63aaa..f51b1ae1da4 100644--- a/api/tests/unit_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_draft_variable.py+++ b/api/tests/unit_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_draft_variable.py@@ -3,6 +3,7 @@ from unittest.mock import MagicMock, patchimport pytestfrom flask import Flask, Response+from controllers.common.errors import InvalidArgumentError, NotFoundErrorfrom controllers.console import console_nsfrom controllers.console.app.error import DraftWorkflowNotExistfrom controllers.console.datasets.rag_pipeline.rag_pipeline_draft_variable import (@@ -13,7 +14,6 @@ from controllers.console.datasets.rag_pipeline.rag_pipeline_draft_variable imporRagPipelineVariableCollectionApi,RagPipelineVariableResetApi,)-from controllers.web.error import InvalidArgumentError, NotFoundErrorfrom core.workflow.variable_prefixes import SYSTEM_VARIABLE_NODE_IDfrom graphon.variables.types import SegmentTypefrom models.account import Account, TenantAccountRolediff --git a/api/tests/unit_tests/controllers/console/test_human_input_form.py b/api/tests/unit_tests/controllers/console/test_human_input_form.pyindex 956b034673d..a9e847d7d7c 100644--- a/api/tests/unit_tests/controllers/console/test_human_input_form.py+++ b/api/tests/unit_tests/controllers/console/test_human_input_form.py@@ -9,6 +9,7 @@ from unittest.mock import Mockimport pytestfrom flask import Flask, Response+from controllers.common.errors import NotFoundErrorfrom controllers.common.human_input import HumanInputFormSubmitPayloadfrom controllers.console.human_input_form import (ConsoleHumanInputFormApi,@@ -17,7 +18,6 @@ from controllers.console.human_input_form import (WorkflowResponseConverter,_jsonify_form_definition,)-from controllers.web.error import NotFoundErrorfrom models.account import AccountStatusfrom models.enums import CreatorUserRolefrom models.human_input import RecipientTypediff --git a/api/tests/unit_tests/controllers/web/test_error.py b/api/tests/unit_tests/controllers/web/test_error.pyindex 0387d002bab..2852c4806c9 100644--- a/api/tests/unit_tests/controllers/web/test_error.py+++ b/api/tests/unit_tests/controllers/web/test_error.py@@ -4,6 +4,7 @@ from __future__ import annotationsimport pytest+from controllers.common.errors import InvalidArgumentError, NotFoundErrorfrom controllers.web.error import (AppMoreLikeThisDisabledError,AppSuggestedQuestionsAfterAnswerDisabledError,@@ -11,12 +12,10 @@ from controllers.web.error import (AudioTooLargeError,CompletionRequestError,ConversationCompletedError,- InvalidArgumentError,InvokeRateLimitError,NoAudioUploadedError,NotChatAppError,NotCompletionAppError,- NotFoundError,NotWorkflowAppError,ProviderModelCurrentlyNotSupportError,ProviderNotInitializeError,diff --git a/api/tests/unit_tests/controllers/web/test_workflow_events.py b/api/tests/unit_tests/controllers/web/test_workflow_events.pyindex 64c09b5e220..ab2ca7dde67 100644--- a/api/tests/unit_tests/controllers/web/test_workflow_events.py+++ b/api/tests/unit_tests/controllers/web/test_workflow_events.py@@ -8,7 +8,7 @@ from unittest.mock import MagicMock, patchimport pytestfrom flask import Flask-from controllers.web.error import NotFoundError+from controllers.common.errors import NotFoundErrorfrom controllers.web.workflow_events import WorkflowEventsApifrom models.enums import CreatorUserRolediff --git a/api/tests/unit_tests/factories/test_variable_factory.py b/api/tests/unit_tests/factories/test_variable_factory.pyindex 2439409e803..fdaf98c86a0 100644--- a/api/tests/unit_tests/factories/test_variable_factory.py+++ b/api/tests/unit_tests/factories/test_variable_factory.py@@ -200,6 +200,19 @@ def test_variable_cannot_large_than_200_kb():)+def test_conversation_variable_description_cannot_exceed_255_chars():+ with pytest.raises(VariableError, match="description of variable 'test_text' is too long"):+ variable_factory.build_conversation_variable_from_mapping(+ {+ "id": str(uuid4()),+ "value_type": "string",+ "name": "test_text",+ "value": "value",+ "description": "a" * 256,+ }+ )++def test_array_none_variable():var = variable_factory.build_segment([None, None, None, None])assert isinstance(var, ArrayAnySegment)diff --git a/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py b/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.pyindex 4e10dddd2b1..5fb83a1cf86 100644--- a/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py+++ b/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py@@ -31,6 +31,7 @@ from services.workflow_draft_variable_service import (DraftVariableSaver,VariableResetError,WorkflowDraftVariableService,+ _model_to_insertion_dict,)@@ -643,3 +644,53 @@ class TestWorkflowDraftVariableService:assert node_var.visible == Trueassert node_var.editable == Trueassert node_var.node_execution_id == "exec-id"+++class TestModelToInsertionDict:+ """Reproduce two production errors in _model_to_insertion_dict / _new()."""++ def test_visible_and_is_default_value_always_present(self):+ """Problem 1: _new() did not set visible/is_default_value, causing+ inconsistent dict keys across rows in multi-row INSERT and missing+ is_default_value in the insertion dict entirely.+ """+ conv_var = WorkflowDraftVariable.new_conversation_variable(+ app_id="app-1",+ name="counter",+ value=StringSegment(value="0"),+ )+ # _new() should explicitly set these fields so they are not None+ assert conv_var.visible is not None+ assert conv_var.is_default_value is not None++ d = _model_to_insertion_dict(conv_var)+ # visible must appear in every row's dict+ assert "visible" in d+ # is_default_value must always be present+ assert "is_default_value" in d++ def test_description_passthrough(self):+ """_model_to_insertion_dict passes description as-is;+ length validation is enforced earlier in build_conversation_variable_from_mapping.+ """+ desc = "a" * 200+ conv_var = WorkflowDraftVariable.new_conversation_variable(+ app_id="app-1",+ name="counter",+ value=StringSegment(value="0"),+ description=desc,+ )+ d = _model_to_insertion_dict(conv_var)+ assert d["description"] == desc++ def test_is_default_value_omitted_when_none(self):+ conv_var = WorkflowDraftVariable.new_conversation_variable(+ app_id="app-1",+ name="counter",+ value=StringSegment(value="0"),+ )+ conv_var.is_default_value = None++ d = _model_to_insertion_dict(conv_var)++ assert "is_default_value" not in ddiff --git a/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/use-variable-modal-state.spec.ts b/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/use-variable-modal-state.spec.tsindex 176650f0ed7..b3e713e4889 100644--- a/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/use-variable-modal-state.spec.ts+++ b/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/use-variable-modal-state.spec.ts@@ -195,6 +195,34 @@ describe('useVariableModalState', () => {expect(onClose).not.toHaveBeenCalled()})+ it('should notify and stop saving when description exceeds the limit', () => {+ const notify = vi.fn()+ const onSave = vi.fn()+ const onClose = vi.fn()+ const { result } = renderHook(() => useVariableModalState(createOptions({+ notify,+ onClose,+ onSave,+ })))++ act(() => {+ result.current.handleVarNameChange({ target: { value: 'greeting' } } as ChangeEvent<HTMLInputElement>)+ result.current.handleStringOrNumberChange(['hello'])+ result.current.setDescription('a'.repeat(256))+ })++ act(() => {+ result.current.handleSave()+ })++ expect(notify).toHaveBeenCalledWith({+ type: 'error',+ message: 'chatVariable.modal.descriptionTooLong',+ })+ expect(onSave).not.toHaveBeenCalled()+ expect(onClose).not.toHaveBeenCalled()+ })+it('should save a new variable and close when state is valid', () => {const onSave = vi.fn()const onClose = vi.fn()diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/variable-modal.sections.spec.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/variable-modal.sections.spec.tsxindex 5f644077640..80df7de00f7 100644--- a/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/variable-modal.sections.spec.tsx+++ b/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/variable-modal.sections.spec.tsx@@ -24,6 +24,7 @@ describe('variable-modal sections', () => {/><DescriptionSectiondescription="original description"+ maxLength={255}onChange={onDescriptionChange}placeholder="description-placeholder"title="Description"@@ -43,6 +44,20 @@ describe('variable-modal sections', () => {expect(onDescriptionChange).toHaveBeenCalledWith('updated-description')})+ it('should show description length against the configured limit', () => {+ render(+ <DescriptionSection+ description="abc"+ maxLength={255}+ onChange={vi.fn()}+ placeholder="description-placeholder"+ title="Description"+ />,+ )++ expect(screen.getByText('3/255')).toBeInTheDocument()+ })+it('renders type and value sections and forwards toggle and value changes', async () => {const onSelect = vi.fn()const onArrayChange = vi.fn()diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/use-variable-modal-state.ts b/web/app/components/workflow/panel/chat-variable-panel/components/use-variable-modal-state.tsindex 07619029a34..343d27e1c80 100644--- a/web/app/components/workflow/panel/chat-variable-panel/components/use-variable-modal-state.ts+++ b/web/app/components/workflow/panel/chat-variable-panel/components/use-variable-modal-state.ts@@ -11,6 +11,7 @@ import {getEditorMinHeight,getPlaceholderByType,getTypeChangeState,+ MAX_DESCRIPTION_LENGTH,parseEditorContent,validateVariableName,} from './variable-modal.helpers'@@ -196,6 +197,17 @@ export const useVariableModalState = ({return}+ if (state.description.length > MAX_DESCRIPTION_LENGTH) {+ notify({+ type: 'error',+ message: t('chatVariable.modal.descriptionTooLong', {+ maxLength: MAX_DESCRIPTION_LENGTH,+ ns: 'workflow',+ }),+ })+ return+ }+onSave({description: state.description,id: chatVar ? chatVar.id : uuid4(),diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.helpers.ts b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.helpers.tsindex 8307cbe80bd..cde72a508fa 100644--- a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.helpers.ts+++ b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.helpers.ts@@ -29,6 +29,8 @@ export type ToastPayload = {customComponent?: ReactNode}+export const MAX_DESCRIPTION_LENGTH = 255+export const typeList = [ChatVarTypeEnum.String,ChatVarTypeEnum.Number,diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.sections.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.sections.tsxindex f208b6a2831..49e9eb879f2 100644--- a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.sections.tsx+++ b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.sections.tsx@@ -1,6 +1,7 @@import type { ReactNode } from 'react'import type { ObjectValueItem } from './variable-modal.helpers'import { Button } from '@langgenius/dify-ui/button'+import { cn } from '@langgenius/dify-ui/cn'import { RiDraftLine, RiInputField } from '@remixicon/react'import Input from '@/app/components/base/input'import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'@@ -195,6 +196,7 @@ export const ValueSection = ({type DescriptionSectionProps = {description: string+ maxLength: numberonChange: (value: string) => voidplaceholder: stringtitle: string@@ -202,6 +204,7 @@ type DescriptionSectionProps = {export const DescriptionSection = ({description,+ maxLength,onChange,placeholder,title,@@ -216,5 +219,10 @@ export const DescriptionSection = ({onChange={e => onChange(e.target.value)}/></div>+ <div className={cn('mt-1 text-right system-xs-regular', description.length > maxLength ? 'text-text-destructive' : 'text-text-quaternary')}>+ {description.length}+ /+ {maxLength}+ </div></div>)diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsxindex 6c2e5fe4498..ecb81b65073 100644--- a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx+++ b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx@@ -12,6 +12,7 @@ import { replaceSpaceWithUnderscoreInVarNameInput } from '@/utils/var'import { useVariableModalState } from './use-variable-modal-state'import {getEditorToggleLabelKey,+ MAX_DESCRIPTION_LENGTH,typeList,validateVariableName,} from './variable-modal.helpers'@@ -72,6 +73,7 @@ const ChatVariableModal = ({returnhandleVarNameChange(e)}+return (<divclassName={cn('flex h-full w-[360px] flex-col rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-2xl', type === ChatVarType.Object && 'w-[480px]')}@@ -127,6 +129,7 @@ const ChatVariableModal = ({/><DescriptionSectiondescription={description}+ maxLength={MAX_DESCRIPTION_LENGTH}onChange={setDescription}placeholder={t('chatVariable.modal.descriptionPlaceholder', { ns: 'workflow' }) || ''}title={t('chatVariable.modal.description', { ns: 'workflow' })}diff --git a/web/i18n/en-US/workflow.json b/web/i18n/en-US/workflow.jsonindex 0521d5b0c8a..1ba4095a60b 100644--- a/web/i18n/en-US/workflow.json+++ b/web/i18n/en-US/workflow.json@@ -90,6 +90,7 @@"chatVariable.modal.arrayValue": "Value","chatVariable.modal.description": "Description","chatVariable.modal.descriptionPlaceholder": "Describe the variable",+ "chatVariable.modal.descriptionTooLong": "Description must be {{maxLength}} characters or less","chatVariable.modal.editInForm": "Edit in Form","chatVariable.modal.editInJSON": "Edit in JSON","chatVariable.modal.editTitle": "Edit Conversation Variable",diff --git a/web/i18n/zh-Hans/workflow.json b/web/i18n/zh-Hans/workflow.jsonindex 450e0a9dd38..3cdddef1121 100644--- a/web/i18n/zh-Hans/workflow.json+++ b/web/i18n/zh-Hans/workflow.json@@ -90,6 +90,7 @@"chatVariable.modal.arrayValue": "值","chatVariable.modal.description": "描述","chatVariable.modal.descriptionPlaceholder": "变量的描述",+ "chatVariable.modal.descriptionTooLong": "描述不能超过 {{maxLength}} 个字符","chatVariable.modal.editInForm": "在表单中编辑","chatVariable.modal.editInJSON": "在 JSON 中编辑","chatVariable.modal.editTitle": "编辑会话变量",