Skip to content

[Bug] Embedded chatbot drops numeric zero defaults and required number values #43242

Closed

Description

@0204zll

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, including closed ones.
  • I confirm that I am using English to submit this report.
  • Please do not modify this template.

Dify version

1.17.1, main at 7b0660b4.

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Create an app with an embedded chatbot and a required Number input whose default value is 0, or open the embedded chatbot with a URL-provided value of 0.
  2. Render the embedded chatbot input form.
  3. Observe the Number input value and try to start the conversation.

A focused regression test on current main reproduces the issue without a model provider.

Expected Behavior

Numeric 0 is a valid Number input value. It should be preserved from app defaults and URL parameters, rendered in the form, and accepted by the required-field validation.

Actual Behavior

Numeric 0 is treated as empty throughout the embedded chatbot input flow:

  • A URL parameter such as n1=0 is replaced by the app default instead of preserving 0.
  • A Number input value of numeric 0 renders as an empty field.
  • A required Number input with numeric 0 is rejected when starting the conversation.

Root Cause

The embedded chatbot form uses truthiness checks in several places:

  • web/app/components/base/chat/embedded-chatbot/hooks.tsx maps the parsed Number value with convertedNumber || item.default || item.number.default.
  • The default-input initialization uses item.default || null.
  • Required-field validation uses !newConversationInputsRef.current[variable].
  • web/app/components/base/chat/embedded-chatbot/inputs-form/content.tsx renders the input as inputsFormValue?.[form.variable] || ''.

Verification

I added three focused regression tests and ran them against current main:

Test Files  2 failed (2)
Tests       3 failed | 49 passed (52)

The failures cover URL parameter 0, required Number 0, and rendering numeric 0 from context.

Additional Context

This differs from workflow Test Run validation in #43240: the affected component and state path here are the embedded chatbot's default/input lifecycle.

Activity

  1. added
    review: low
    on Sep 29, 2026
  2. dosubot commented on Sep 29, 2026

    @dosubot

    Hi @0204zll! I'm Dosu and I'm helping the Dify team.

    All four truthiness-check sites you identified exist in web/app/components/base/chat/embedded-chatbot/hooks.tsx and inputs-form/content.tsx:

    • The number default computation, default: convertedNumber || item.default || item.number.default [1], falls through to the app-level default whenever convertedNumber is 0, so a URL param like n1=0 gets overwritten.
    • The new-conversation input seeding, conversationInputs[item.variable] = item.default || null [2], replaces a default of 0 with null.
    • The required-field check in checkInputsRequired, if (!newConversationInputsRef.current[variable] && !silent) [3], flags a required Number field of 0 as empty. So does the matching check in chat-wrapper.tsx's inputDisabled memo, if (!inputsFormValue?.[variable]) hasEmptyInput = label [4].
    • The render layer, value={inputsFormValue?.[form.variable] || ''} [5], shows 0 as a blank input.

    The sibling chat-with-history flow contains the same item.default || null pattern and the same !newConversationInputsRef.current[variable] and !inputsFormValue?.[variable] checks verbatim [6] [7] [8]. A fix limited to embedded-chatbot would likely leave the bug in place there.

    This is the same class of bug as #43240, which was just filed for Workflow Test Run rejecting 0. It already has an open fix, PR #43241, which changes the required-field guard in check-input-forms-hooks.ts from if (!inputs[variable]) to if (!inputs[variable] && inputs[variable] !== 0). That PR only touches the shared workflow validator hook, not embedded-chatbot/hooks.tsx, chat-wrapper.tsx, or inputs-form/content.tsx, so it won't resolve the paths reported here.

    For the render layer, before-run-form/form-item.tsx already avoids this by rendering value == null || value === '' ? null : Number(value) instead of a truthiness check [9]. A similar approach would fix all four sites you listed: a value === undefined || value === null || value === '' ? '' : value guard for rendering, plus item.default ?? null and variable in obj ? obj[variable] : ... in place of ||.

    Your regression tests already reproduce this, and the fix for #43240 is in progress. That makes this a good candidate for a companion PR covering these four call sites and their chat-with-history counterparts.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dify with Dosu

  3. Stream29 commented on Oct 11, 2026

    @Stream29
    Contributor

    Reproduced the URL zero-value fallback in the published embedded chatbot on self-hosted Docker 1.17.1.

    1. Configure a required Number input amount with default 1, and publish.
    2. Open /chatbot/<app-code> with the gzip + base64 encoded value 0:
      ?amount=H4sIAAAAAAAAAzMAACHf2%2FQBAAAA
      
    3. Expected Amount = 0; actual Amount = 1.

    A read-only check confirmed that the actual URL parameter decoded to 0.

    Required Number input amount with default 1 Widget shows Amount 1 although the decoded URL value is 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    review: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions