Skip to content

Conversation

@QuantumGhost
Copy link
Collaborator

@QuantumGhost QuantumGhost commented Dec 31, 2025

Summary

PR #29053 introduced JSON_OBJECT support for user inputs. It also introduced an optional JSONSchema validation for json object inputs. However, the JSON_OBJECT option is not enabled in chatflow / workflow orchestration page, leading to confusions.

This PR addresses the problem by removing relevant feature flags in frontend code. It also adjusts how the JSONSchema is edited: the original implementation fills the top level properties for the user, while the current implementation only ensures that the type field of JSONSchema is object if the is JSON Schema field is set.

Fix: #29519

Screenshots

Before After
image image

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

@QuantumGhost QuantumGhost requested a review from fatelei December 31, 2025 04:07
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @QuantumGhost, 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 previous limitation where the JSON_OBJECT input type was not fully available in the console UI for chatflow and workflow orchestration. It enables this functionality and enhances the user experience for defining JSON Schemas by improving validation and simplifying the input process, ensuring that users can correctly define object-based inputs.

Highlights

  • Enabled JSON_OBJECT Support: The JSON_OBJECT input type is now fully enabled and accessible in the console UI, specifically for chatflow and workflow orchestration pages, by removing previously restricting feature flags.
  • Improved JSON Schema Editing: The JSON Schema editing experience has been refined. Instead of automatically wrapping user input with top-level properties, the system now expects a complete JSON Schema object and validates that its root type is 'object' if the field is set.
  • Enhanced JSON Schema Validation: New validation has been added to ensure that the provided JSON Schema is syntactically valid JSON and that its top-level type property is correctly set to 'object'.
  • Internationalization Updates: New error messages related to JSON Schema validation have been added and translated across multiple languages to provide clearer feedback to users.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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
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 successfully enables JSON_OBJECT type support in the UI by removing feature flags and adjusting JSON schema handling. The changes are generally well-implemented. However, I've identified a couple of areas for improvement in web/app/components/app/configuration/config-var/config-modal/index.tsx. There's a high-severity issue regarding the unconditional normalization of json_schema, which could lead to incorrect data being saved for non-JSON variable types. Additionally, there's a minor redundancy in a conditional check that could be simplified to improve code clarity.

@QuantumGhost QuantumGhost marked this pull request as ready for review December 31, 2025 04:28
Copilot AI review requested due to automatic review settings December 31, 2025 04:28
@QuantumGhost QuantumGhost requested a review from zxhlyh as a code owner December 31, 2025 04:28
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 31, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables JSON_OBJECT type support in the console UI by removing the isSupportJSON feature flag and adjusting how JSON Schema is edited. Previously, the implementation auto-wrapped user properties in a top-level object structure; now it expects users to provide the complete JSON Schema including the required type: "object" field, with validation to ensure compliance.

Key Changes:

  • Removed isSupportJSON feature flag to enable JSON_OBJECT option in non-basic app modes
  • Changed JSON Schema editing to expect full schema format instead of just properties
  • Added validation for JSON Schema to ensure it's valid JSON with type: "object"

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

File Description
web/app/components/app/configuration/config-var/config-modal/index.tsx Removed feature flag, updated JSON Schema handling logic, added validation for JSON Schema format
web/app/components/app/configuration/config-var/config-modal/config.ts Updated placeholder to show complete JSON Schema structure with top-level type, properties, and required fields
web/i18n/*/app-debug.json (21 files) Added two new error message translations: jsonSchemaInvalid and jsonSchemaMustBeObject for JSON Schema validation errors across all supported languages
Comments suppressed due to low confidence (1)

web/app/components/app/configuration/config-var/config-modal/index.tsx:143

  • The function returns null on empty input (line 134) and parsing errors (line 141), but these return values are never used. The handleJSONSchemaChange callback is passed to the CodeEditor component which likely doesn't utilize the return value. Consider either removing the return statements or documenting why they exist if they serve a specific purpose in the CodeEditor's onChange handler.
  const handleJSONSchemaChange = useCallback((value: string) => {
    const isEmpty = value == null || value.trim() === ''
    if (isEmpty) {
      handlePayloadChange('json_schema')(undefined)
      return null
    }
    try {
      const v = JSON.parse(value)
      handlePayloadChange('json_schema')(JSON.stringify(v, null, 2))
    }
    catch {
      return null
    }
  }, [handlePayloadChange])

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

iamjoel
iamjoel previously approved these changes Dec 31, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 31, 2025
fatelei
fatelei previously approved these changes Dec 31, 2025
@QuantumGhost QuantumGhost dismissed stale reviews from fatelei and iamjoel via cbbede5 December 31, 2025 05:29
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:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON Object input

4 participants