dify - 💡(How to fix) Fix JSON type input var raise Intenal server error [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

2026-05-28 06:30:47.674 ERROR [Dummy-27552] [trace.py:309] 6c73a6f159f75c679d36f6d5ca17bcb9 - Task tasks.app_generate.workflow_execute_task.workflow_based_app_execution_task[5bd8f6ad-fbfa-4a6f-81f0-69e67fc54d72] raised unexpected: 1 validation error for VariableEntity

json_schema

Input should be a valid dictionary [type=dict_type, input_value='{\n "type": "object",\n..."number"\n }\n }\n}', input_type=str]

For further information visit https://errors.pydantic.dev/2.12/v/dict_type

Traceback (most recent call last):

File "/app/api/.venv/lib/python3.12/site-packages/celery/app/trace.py", line 585, in trace_task

R = retval = fun(*args, **kwargs)

             ^^^^^^^^^^^^^^^^^^^^

File "/app/api/extensions/ext_celery.py", line 101, in call

return self.run(*args, **kwargs)

       ^^^^^^^^^^^^^^^^^^^^^^^^^

File "/app/api/tasks/app_generate/workflow_execute_task.py", line 269, in workflow_based_app_execution_task

return runner.run()

       ^^^^^^^^^^^^

File "/app/api/tasks/app_generate/workflow_execute_task.py", line 165, in run

response = self._run_app(

           ^^^^^^^^^^^^^^

File "/app/api/tasks/app_generate/workflow_execute_task.py", line 187, in _run_app

return AdvancedChatAppGenerator().generate(

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/app/api/core/app/apps/advanced_chat/app_generator.py", line 172, in generate

app_config = AdvancedChatAppConfigManager.get_app_config(app_model=app_model, workflow=workflow)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/app/api/core/app/apps/advanced_chat/app_config_manager.py", line 36, in get_app_config

variables=WorkflowVariablesConfigManager.convert(workflow=workflow),

          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/app/api/core/app/app_config/workflow_ui_based_app/variables/manager.py", line 23, in convert

variables.append(VariableEntity.model_validate(variable))

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/app/api/.venv/lib/python3.12/site-packages/pydantic/main.py", line 716, in model_validate

return cls.__pydantic_validator__.validate_python(

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

pydantic_core._pydantic_core.ValidationError: 1 validation error for VariableEntity

json_schema

Input should be a valid dictionary [type=dict_type, input_value='{\n "type": "object",\n..."number"\n }\n }\n}', input_type=str]

For further information visit https://errors.pydantic.dev/2.12/v/dict_type

Fix Action

Fixed

Code Example

2026-05-28 06:30:47.674 ERROR [Dummy-27552] [trace.py:309] 6c73a6f159f75c679d36f6d5ca17bcb9 - Task tasks.app_generate.workflow_execute_task.workflow_based_app_execution_task[5bd8f6ad-fbfa-4a6f-81f0-69e67fc54d72] raised unexpected: 1 validation error for VariableEntity

json_schema

  Input should be a valid dictionary [type=dict_type, input_value='{\n  "type": "object",\n..."number"\n    }\n  }\n}', input_type=str]

    For further information visit https://errors.pydantic.dev/2.12/v/dict_type

Traceback (most recent call last):

  File "/app/api/.venv/lib/python3.12/site-packages/celery/app/trace.py", line 585, in trace_task

    R = retval = fun(*args, **kwargs)

                 ^^^^^^^^^^^^^^^^^^^^

  File "/app/api/extensions/ext_celery.py", line 101, in __call__

    return self.run(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/tasks/app_generate/workflow_execute_task.py", line 269, in workflow_based_app_execution_task

    return runner.run()

           ^^^^^^^^^^^^

  File "/app/api/tasks/app_generate/workflow_execute_task.py", line 165, in run

    response = self._run_app(

               ^^^^^^^^^^^^^^

  File "/app/api/tasks/app_generate/workflow_execute_task.py", line 187, in _run_app

    return AdvancedChatAppGenerator().generate(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/core/app/apps/advanced_chat/app_generator.py", line 172, in generate

    app_config = AdvancedChatAppConfigManager.get_app_config(app_model=app_model, workflow=workflow)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/core/app/apps/advanced_chat/app_config_manager.py", line 36, in get_app_config

    variables=WorkflowVariablesConfigManager.convert(workflow=workflow),

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/core/app/app_config/workflow_ui_based_app/variables/manager.py", line 23, in convert

    variables.append(VariableEntity.model_validate(variable))

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/.venv/lib/python3.12/site-packages/pydantic/main.py", line 716, in model_validate

    return cls.__pydantic_validator__.validate_python(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

pydantic_core._pydantic_core.ValidationError: 1 validation error for VariableEntity

json_schema

  Input should be a valid dictionary [type=dict_type, input_value='{\n  "type": "object",\n..."number"\n    }\n  }\n}', input_type=str]

    For further information visit https://errors.pydantic.dev/2.12/v/dict_type

---

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "age": {
      "type": "number"
    }
  }
}

---

class VariableEntity(BaseModel):
    """Shared variable entity used by workflow runtime and app configuration."""

    # `variable` records the name of the variable in user inputs.
    variable: str
    label: str
    description: str = ""
    type: VariableEntityType
    required: bool = False
    hide: bool = False
    default: Any = None
    max_length: int | None = None
    options: Sequence[str] = Field(default_factory=list)
    allowed_file_types: Sequence[FileType] | None = Field(default_factory=list)
    allowed_file_extensions: Sequence[str] | None = Field(default_factory=list)
    allowed_file_upload_methods: Sequence[FileTransferMethod] | None = Field(
        default_factory=list,
    )
    json_schema: dict[str, Any] | None = Field(default=None)

    @field_validator("description", mode="before")
    @classmethod
    def convert_none_description(cls, value: Any) -> str:
        return value or ""

    @field_validator("options", mode="before")
    @classmethod
    def convert_none_options(cls, value: Any) -> Sequence[str]:
        return value or []

    @field_validator("json_schema")
    @classmethod
    def validate_json_schema(
        cls,
        schema: dict[str, Any] | None,
    ) -> dict[str, Any] | None:
        if schema is None:
            return None
        try:
            Draft7Validator.check_schema(schema)
        except SchemaError as error:
            msg = f"Invalid JSON schema: {error.message}"
            raise ValueError(msg) from error
        return schema
RAW_BUFFERClick to expand / collapse

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.14.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

worker container

2026-05-28 06:30:47.674 ERROR [Dummy-27552] [trace.py:309] 6c73a6f159f75c679d36f6d5ca17bcb9 - Task tasks.app_generate.workflow_execute_task.workflow_based_app_execution_task[5bd8f6ad-fbfa-4a6f-81f0-69e67fc54d72] raised unexpected: 1 validation error for VariableEntity

json_schema

  Input should be a valid dictionary [type=dict_type, input_value='{\n  "type": "object",\n..."number"\n    }\n  }\n}', input_type=str]

    For further information visit https://errors.pydantic.dev/2.12/v/dict_type

Traceback (most recent call last):

  File "/app/api/.venv/lib/python3.12/site-packages/celery/app/trace.py", line 585, in trace_task

    R = retval = fun(*args, **kwargs)

                 ^^^^^^^^^^^^^^^^^^^^

  File "/app/api/extensions/ext_celery.py", line 101, in __call__

    return self.run(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/tasks/app_generate/workflow_execute_task.py", line 269, in workflow_based_app_execution_task

    return runner.run()

           ^^^^^^^^^^^^

  File "/app/api/tasks/app_generate/workflow_execute_task.py", line 165, in run

    response = self._run_app(

               ^^^^^^^^^^^^^^

  File "/app/api/tasks/app_generate/workflow_execute_task.py", line 187, in _run_app

    return AdvancedChatAppGenerator().generate(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/core/app/apps/advanced_chat/app_generator.py", line 172, in generate

    app_config = AdvancedChatAppConfigManager.get_app_config(app_model=app_model, workflow=workflow)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/core/app/apps/advanced_chat/app_config_manager.py", line 36, in get_app_config

    variables=WorkflowVariablesConfigManager.convert(workflow=workflow),

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/core/app/app_config/workflow_ui_based_app/variables/manager.py", line 23, in convert

    variables.append(VariableEntity.model_validate(variable))

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/api/.venv/lib/python3.12/site-packages/pydantic/main.py", line 716, in model_validate

    return cls.__pydantic_validator__.validate_python(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

pydantic_core._pydantic_core.ValidationError: 1 validation error for VariableEntity

json_schema

  Input should be a valid dictionary [type=dict_type, input_value='{\n  "type": "object",\n..."number"\n    }\n  }\n}', input_type=str]

    For further information visit https://errors.pydantic.dev/2.12/v/dict_type

Step:

  1. Init a JSON type input var in Start node and input json schema.
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "age": {
      "type": "number"
    }
  }
}
  1. Input json var value {"name":"abc","age":10} and start chat.

Position: https://github.com/langgenius/dify/blob/57b02e341ccbbad0d3860b24b9ed7020876c389d/api/core/app/app_config/workflow_ui_based_app/variables/manager.py#L8-L25

https://github.com/langgenius/graphon/blob/7c300aec3dad2b420bbe259f48a4c1cde1250f97/src/graphon/variables/input_entities.py#L26-L69

class VariableEntity(BaseModel):
    """Shared variable entity used by workflow runtime and app configuration."""

    # `variable` records the name of the variable in user inputs.
    variable: str
    label: str
    description: str = ""
    type: VariableEntityType
    required: bool = False
    hide: bool = False
    default: Any = None
    max_length: int | None = None
    options: Sequence[str] = Field(default_factory=list)
    allowed_file_types: Sequence[FileType] | None = Field(default_factory=list)
    allowed_file_extensions: Sequence[str] | None = Field(default_factory=list)
    allowed_file_upload_methods: Sequence[FileTransferMethod] | None = Field(
        default_factory=list,
    )
    json_schema: dict[str, Any] | None = Field(default=None)

    @field_validator("description", mode="before")
    @classmethod
    def convert_none_description(cls, value: Any) -> str:
        return value or ""

    @field_validator("options", mode="before")
    @classmethod
    def convert_none_options(cls, value: Any) -> Sequence[str]:
        return value or []

    @field_validator("json_schema")
    @classmethod
    def validate_json_schema(
        cls,
        schema: dict[str, Any] | None,
    ) -> dict[str, Any] | None:
        if schema is None:
            return None
        try:
            Draft7Validator.check_schema(schema)
        except SchemaError as error:
            msg = f"Invalid JSON schema: {error.message}"
            raise ValueError(msg) from error
        return schema

✔️ Expected Behavior

No error raised.

❌ Actual Behavior

Chat will be Blocked.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING