Skip to content

fix: variable assigner can't assign float number#28068

Merged
crazywoola merged 1 commit intolanggenius:mainfrom
hjlarry:p301
Nov 12, 2025
Merged

fix: variable assigner can't assign float number#28068
crazywoola merged 1 commit intolanggenius:mainfrom
hjlarry:p301

Conversation

@hjlarry
Copy link
Copy Markdown
Contributor

@hjlarry hjlarry commented Nov 11, 2025

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

fix #28030

error log:

2025-11-11 01:07:06,630 INFO [debug_logging.py:164]  ✅ Node succeeded: 1762822713123
Debugging middleware caught exception in streamed response at a point where response headers were already sent.
Traceback (most recent call last):
  File "/root/dify/api/.venv/lib/python3.12/site-packages/werkzeug/wsgi.py", line 256, in __next__
    return self._next()
           ^^^^^^^^^^^^
  File "/root/dify/api/.venv/lib/python3.12/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded
    for item in iterable:
  File "/root/dify/api/.venv/lib/python3.12/site-packages/flask/helpers.py", line 132, in generator
    yield from gen
  File "/root/dify/api/libs/helper.py", line 209, in generate
    yield from response
  File "/root/dify/api/core/app/features/rate_limiting/rate_limit.py", line 120, in __next__
    return next(self.generator)
           ^^^^^^^^^^^^^^^^^^^^
  File "/root/dify/api/core/app/apps/base_app_generator.py", line 176, in gen
    for message in generator:
  File "/root/dify/api/core/app/apps/base_app_generate_response_converter.py", line 27, in _generate_full_response
    yield from cls.convert_stream_full_response(response)
  File "/root/dify/api/core/app/apps/advanced_chat/generate_response_converter.py", line 66, in convert_stream_full_response
    for chunk in stream_response:
  File "/root/dify/api/core/app/apps/advanced_chat/generate_task_pipeline.py", line 202, in _to_stream_response
    for stream_response in generator:
  File "/root/dify/api/core/app/apps/advanced_chat/generate_task_pipeline.py", line 235, in _wrapper_process_stream_response
    for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager):
  File "/root/dify/api/core/app/apps/advanced_chat/generate_task_pipeline.py", line 757, in _process_stream_response
    if responses := list(
                    ^^^^^
  File "/root/dify/api/core/app/apps/advanced_chat/generate_task_pipeline.py", line 699, in _dispatch_event
    yield from handler(
  File "/root/dify/api/core/app/apps/advanced_chat/generate_task_pipeline.py", line 356, in _handle_node_succeeded_event
    self._save_output_for_event(event, event.node_execution_id)
  File "/root/dify/api/core/app/apps/advanced_chat/generate_task_pipeline.py", line 891, in _save_output_for_event
    saver.save(event.process_data, event.outputs)
  File "/root/dify/api/services/workflow_draft_variable_service.py", line 1028, in save
    draft_vars = self._build_from_variable_assigner_mapping(process_data=process_data)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/dify/api/services/workflow_draft_variable_service.py", line 811, in _build_from_variable_assigner_mapping
    segment = WorkflowDraftVariable.build_segment_with_type(segment_type=item.value_type, value=item.new_value)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/dify/api/models/workflow.py", line 1376, in build_segment_with_type
    return build_segment_with_type(segment_type=segment_type, value=value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/dify/api/factories/variable_factory.py", line 278, in build_segment_with_type
    raise TypeMismatchError(f"Type mismatch: expected {segment_type}, but got {inferred_type}, value={value}")
factories.variable_factory.TypeMismatchError: Type mismatch: expected integer, but got float, value=111.1

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@hjlarry hjlarry requested review from QuantumGhost and Copilot and removed request for Copilot November 11, 2025 01:26
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Nov 11, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @hjlarry, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug where the system's variable assigner failed to correctly process float numbers for conversation variables that were internally designated as integers. The fix modifies the type handling during variable assignment, ensuring that values are appropriately cast to a more general 'NUMBER' type when an INTEGER type is encountered, thereby preventing TypeMismatchError and improving the robustness of variable assignment within the workflow.

Highlights

  • Bug Fix: Resolves a TypeMismatchError that occurred when attempting to assign float numbers to conversation variables internally typed as integers.
  • Type Handling Improvement: Adjusts the variable assignment logic to allow conversation variables, which are exposed as generic 'NUMBER' types in the UI, to correctly accept float values even if their underlying persisted type is INTEGER.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a bug where assigning a float value to a variable of type integer would cause a TypeMismatchError. The fix correctly identifies the issue and loosens the type check to NUMBER for conversation variables that are of type INTEGER.

I've added one suggestion to make the fix more robust by using the existing exposed_type() method, which will handle both INTEGER and FLOAT types consistently with how they are presented in the UI. This improves maintainability and aligns with the existing type system logic.

Overall, the change is correct and addresses the reported issue.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 11, 2025
@crazywoola crazywoola merged commit 6026bd8 into langgenius:main Nov 12, 2025
17 checks passed
frf12 pushed a commit to oceanbase/dify-on-mysql that referenced this pull request Nov 13, 2025
* fix(api): Trace Hierarchy, Span Status, and Broken Workflow for Arize & Phoenix Integration (langgenius#27937)

Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>

* chore: add type-check to pre-commit (langgenius#28005)

* fix document enable (langgenius#28081)

* chore: not SaaS version can query long log time range (langgenius#28109)

* When graph_engine worker run exception, keep the node_id for deep res… (langgenius#26205)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: -LAN- <laipz8200@outlook.com>

* fix document index test (langgenius#28113)

* chore: improve the user experience of not login into apps (langgenius#28120)

* feat(api): Introduce `WorkflowResumptionContext` for pause state management (langgenius#28122)

Certain metadata (including but not limited to `InvokeFrom`, `call_depth`, and `streaming`)  is required when resuming a paused workflow. However, these fields are not part of `GraphRuntimeState` and were not saved in the previous
 implementation of  `PauseStatePersistenceLayer`.

This commit addresses this limitation by introducing a `WorkflowResumptionContext` model that wraps both the `*GenerateEntity` and `GraphRuntimeState`. This approach provides:

- A structured container for all necessary resumption data
- Better separation of concerns between execution state and persistence
- Enhanced extensibility for future metadata additions
- Clearer naming that distinguishes from `GraphRuntimeState`

The `WorkflowResumptionContext` model makes extending the pause state easier while maintaining backward compatibility and proper version management for the entire execution state ecosystem.

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* add transform-datasource-credentials command online check (langgenius#28124)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Garfield Dai <dai.hai@foxmail.com>

* feat: introduce trigger functionality (langgenius#27644)

Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: Stream <Stream_2@qq.com>
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: zhsama <torvalds@linux.do>
Co-authored-by: Harry <xh001x@hotmail.com>
Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: yessenia <yessenia.contact@gmail.com>
Co-authored-by: hjlarry <hjlarry@163.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: WTW0313 <twwu@dify.ai>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: determine cpu cores determination in baseedpyright-check script on macos  (langgenius#28058)

* fix: variable assigner can't assign float number (langgenius#28068)

* Add file type validation to paste upload (langgenius#28017)

* test: create some hooks and utils test script, modified clipboard test script (langgenius#27928)

* convert to TypeBase (langgenius#27935)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: disable workflow logs auto-cleanup by default (langgenius#28136)

This PR changes the default value of `WORKFLOW_LOG_CLEANUP_ENABLED` from `true` to `false` across all configuration files.

## Motivation

Setting the default to `false` provides safer default behavior by:

- Preventing unintended data loss for new installations
- Giving users explicit control over when to enable log cleanup
- Following the opt-in principle for data deletion features

Users who need automatic cleanup can enable it by setting `WORKFLOW_LOG_CLEANUP_ENABLED=true` in their configuration.

* fix: simplify graph structure validation in WorkflowService (langgenius#28146)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* fix: app's ai site text to speech api (langgenius#28091)

* refactor(web): reuse the same edit-custom-collection-modal component, and fix the pop up error (langgenius#28003)

* add doc (langgenius#28016)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* fix: inconsistent behaviour of zoom in button and shortcut (langgenius#27944)

* consolve conficts

* fix

* fix

---------

Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: Ali Saleh <saleh.a@turing.com>
Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com>
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: 湛露先生 <zhanluxianshen@163.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: -LAN- <laipz8200@outlook.com>
Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com>
Co-authored-by: Garfield Dai <dai.hai@foxmail.com>
Co-authored-by: Yeuoly <45712896+Yeuoly@users.noreply.github.com>
Co-authored-by: Stream <Stream_2@qq.com>
Co-authored-by: zhsama <torvalds@linux.do>
Co-authored-by: Harry <xh001x@hotmail.com>
Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: yessenia <yessenia.contact@gmail.com>
Co-authored-by: hjlarry <hjlarry@163.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: WTW0313 <twwu@dify.ai>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Bowen Liang <liang.bowen.123@qq.com>
Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com>
Co-authored-by: Gritty_dev <101377478+codomposer@users.noreply.github.com>
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
Co-authored-by: mnasrautinno <m.nasr@dai.autinno.com>
Co-authored-by: yangzheli <43645580+yangzheli@users.noreply.github.com>
Xiu-Lan pushed a commit to AICT-Team/dify that referenced this pull request Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Abnormal workflow termination

2 participants