Repository navigation
fix: normalize json_schema from string to dict in VariableEntity - #36777
Merged
crazywoola merged 1 commit intoJun 3, 2026
Merged
Conversation
When workflow graph data is loaded from the database, the json_schema field of JSON object variables may be stored as a JSON string rather than a native dict. VariableEntity.json_schema expects dict | None, causing a Pydantic ValidationError. Add a _normalize_json_schema helper that deserializes the string before passing to model_validate, with a regression test. Fixes langgenius#36766
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-05-28 08:33:03.678747182 +0000
+++ /tmp/pyrefly_pr.txt 2026-05-28 08:32:50.306689067 +0000
@@ -2738,10 +2738,18 @@
--> tests/unit_tests/core/app/app_config/test_base_app_config_manager.py:156:69
ERROR Argument `Literal['CHAT']` is not assignable to parameter `app_mode` with type `AppMode` in function `core.app.app_config.base_app_config_manager.BaseAppConfigManager.convert_features` [bad-argument-type]
--> tests/unit_tests/core/app/app_config/test_base_app_config_manager.py:178:71
+ERROR Cannot index into `VariableEntity` [bad-index]
+ --> tests/unit_tests/core/app/app_config/workflow_ui_based_app/test_workflow_ui_based_app_manager.py:97:16
+ERROR Cannot index into `VariableEntity` [bad-index]
+ --> tests/unit_tests/core/app/app_config/workflow_ui_based_app/test_workflow_ui_based_app_manager.py:118:16
+ERROR Cannot index into `VariableEntity` [bad-index]
+ --> tests/unit_tests/core/app/app_config/workflow_ui_based_app/test_workflow_ui_based_app_manager.py:137:16
+ERROR Cannot index into `VariableEntity` [bad-index]
+ --> tests/unit_tests/core/app/app_config/workflow_ui_based_app/test_workflow_ui_based_app_manager.py:156:16
ERROR Cannot index into `RagPipelineVariableEntity` [bad-index]
- --> tests/unit_tests/core/app/app_config/workflow_ui_based_app/test_workflow_ui_based_app_manager.py:141:16
+ --> tests/unit_tests/core/app/app_config/workflow_ui_based_app/test_workflow_ui_based_app_manager.py:222:16
ERROR Cannot index into `RagPipelineVariableEntity` [bad-index]
- --> tests/unit_tests/core/app/app_config/workflow_ui_based_app/test_workflow_ui_based_app_manager.py:166:16
+ --> tests/unit_tests/core/app/app_config/workflow_ui_based_app/test_workflow_ui_based_app_manager.py:247:16
ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `core.app.apps.advanced_chat.app_config_manager.AdvancedChatAppConfigManager.get_app_config` [bad-argument-type]
--> tests/unit_tests/core/app/apps/advanced_chat/test_app_config_manager.py:23:70
ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `core.app.apps.advanced_chat.app_config_manager.AdvancedChatAppConfigManager.get_app_config` [bad-argument-type]
|
Contributor
Pyrefly Type Coverage
|
crazywoola
approved these changes
Jun 3, 2026
crazywoola
enabled auto-merge
June 3, 2026 04:33
6 tasks done
Ssazurov
pushed a commit
to Ssazurov/dify
that referenced
this pull request
Aug 8, 2026
xhdnoah
pushed a commit
to xhdnoah/dify
that referenced
this pull request
Oct 30, 2026
…ggenius#36777) (cherry picked from commit 5a0ad4e)
wylswz
pushed a commit
that referenced
this pull request
Oct 30, 2026
) (cherry picked from commit 5a0ad4e)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #36766
close #36866
close #36895
When workflow graph data is loaded from the database, the
json_schemafield of JSON object variables may be stored as a JSON string rather than a nativedict.VariableEntity.json_schemaexpectsdict | None, causing a PydanticValidationError:Changes
api/core/app/app_config/workflow_ui_based_app/variables/manager.py: Added_normalize_json_schema()helper that deserializes a JSON string to a dict before passing tomodel_validate.api/tests/.../test_workflow_ui_based_app_manager.py: Added regression testtest_convert_normalizes_json_schema_string_to_dict.Root Cause
Database JSON columns may serialize nested dicts as strings depending on the ORM/driver path. When loading an existing workflow with a
json_objectvariable whosejson_schemawas stored as a string, theVariableEntitymodel rejects it.Test Plan
pytest api/tests/unit_tests/core/app/app_config/workflow_ui_based_app/test_workflow_ui_based_app_manager.py -v