Skip to content

feat(agent): support JSON object input on begin node - #16685

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
tecpie:feature/begin-object-input
Jul 7, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:mainfrom
tecpie:feature/begin-object-input

Conversation

@huang-aoqin

Copy link
Copy Markdown
Contributor

Summary

Add object as a begin-node parameter type with JSON editor UI, webhook schema support, and backend parsing in UserFillUp.

Add object as a begin-node parameter type with JSON editor UI, webhook schema support, and backend parsing in UserFillUp.

Co-authored-by: Cursor <[email protected]>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new "object" data type across agent constants, translations, debug-content form schema/rendering, and webhook request body operators, paired with a backend change that parses JSON strings for object-typed fillup values instead of returning them raw.

Changes

Object Type Support

Layer / File(s) Summary
Type constants and icon/type maps
web/src/pages/agent/constant/index.tsx
Adds BeginQueryType.Object, WebhookRequestParameters.Object, maps them to the Braces icon and TypesWithArray.Object.
Debug-content schema and rendering
web/src/pages/agent/debug-content/index.tsx
Adds a Zod union schema (record or array) with default {} for Object fields and a renderer case using JsonEditor bound to the form field.
Webhook body operator list
web/src/pages/agent/form/begin-form/webhook/request-schema.tsx
Includes WebhookRequestParameters.Object in bodyOperatorList for non-multipart content types.
Locale entries
web/src/locales/en.ts, web/src/locales/zh.ts
Adds object translation keys ("JSON object" / "JSON 对象").
Backend fillup value parsing
agent/component/fillup.py
Parses string values as JSON for object-typed inputs, falling back to the raw value on parse failure.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DebugContent
  participant JsonEditor
  participant FormField

  User->>DebugContent: select Object type field
  DebugContent->>JsonEditor: render field.value (default {})
  User->>JsonEditor: edit JSON content
  JsonEditor->>FormField: field.onChange(parsedValue)
Loading

Poem

A rabbit hops through curly braces bright,
{} to {"data": "delight"},
JSON blooms where objects grow,
Webhook fields now know the flow. 🐇✨
Hop, parse, and render — all just right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding JSON object input support on the begin node.
Description check ✅ Passed The description matches the repository template and clearly summarizes the PR's purpose.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent/component/fillup.py`:
- Around line 79-85: The object-value parsing in the fillup logic is too broad
and hides parse failures; update the parsing path in the value extraction helper
in component/fillup.py to catch only JSON decode errors instead of Exception.
Add logging for the parse-failure branch so when json.loads(raw) fails and the
code falls back to returning the raw string, the reason is recorded for
debugging malformed webhook/object payloads. Keep the existing raw-return
behavior, but make the failure path explicit and logged in the function that
handles value.get("type") == "object".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: abcdf1b3-5654-418f-99b8-b2d2a7bbfaa2

📥 Commits

Reviewing files that changed from the base of the PR and between 863b35d and fedeae0.

📒 Files selected for processing (6)
  • agent/component/fillup.py
  • web/src/locales/en.ts
  • web/src/locales/zh.ts
  • web/src/pages/agent/constant/index.tsx
  • web/src/pages/agent/debug-content/index.tsx
  • web/src/pages/agent/form/begin-form/webhook/request-schema.tsx

Comment thread agent/component/fillup.py
Comment on lines +79 to +85
raw = value.get("value")
if value.get("type") == "object" and isinstance(raw, str) and raw.strip():
try:
return json.loads(raw)
except Exception:
return raw
return raw

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Narrow the exception handling and add logging for the new parse-failure path.

except Exception (flagged by Ruff BLE001) swallows unrelated errors beyond JSON decoding, and no logging records why a value was returned raw instead of parsed — making malformed webhook/object payloads hard to diagnose in production. As per coding guidelines, new flows in .py files should add logging (**/*.py: "Add logging for new flows").

🛠️ Proposed fix
             raw = value.get("value")
             if value.get("type") == "object" and isinstance(raw, str) and raw.strip():
                 try:
                     return json.loads(raw)
-                except Exception:
+                except json.JSONDecodeError:
+                    logging.warning("Failed to parse object-typed fillup value as JSON, returning raw string")
                     return raw
             return raw
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
raw = value.get("value")
if value.get("type") == "object" and isinstance(raw, str) and raw.strip():
try:
return json.loads(raw)
except Exception:
return raw
return raw
raw = value.get("value")
if value.get("type") == "object" and isinstance(raw, str) and raw.strip():
try:
return json.loads(raw)
except json.JSONDecodeError:
logging.warning("Failed to parse object-typed fillup value as JSON, returning raw string")
return raw
return raw
🧰 Tools
🪛 Ruff (0.15.20)

[warning] 83-83: Do not catch blind exception: Exception

(BLE001)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent/component/fillup.py` around lines 79 - 85, The object-value parsing in
the fillup logic is too broad and hides parse failures; update the parsing path
in the value extraction helper in component/fillup.py to catch only JSON decode
errors instead of Exception. Add logging for the parse-failure branch so when
json.loads(raw) fails and the code falls back to returning the raw string, the
reason is recorded for debugging malformed webhook/object payloads. Keep the
existing raw-return behavior, but make the failure path explicit and logged in
the function that handles value.get("type") == "object".

Sources: Coding guidelines, Linters/SAST tools

@yingfeng

yingfeng commented Jul 7, 2026

Copy link
Copy Markdown
Member

Thank you. Please submit your changes to the Go implementation. The Python backend will be transitioned to legacy support.

@yuzhichang
yuzhichang self-requested a review July 7, 2026 03:19

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 7, 2026
@yuzhichang yuzhichang added the ci Continue Integration label Jul 7, 2026
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (ab5958f) to head (fedeae0).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16685   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yuzhichang
yuzhichang merged commit 318045d into infiniflow:main Jul 7, 2026
15 checks passed
@huang-aoqin
huang-aoqin deleted the feature/begin-object-input branch July 7, 2026 05:18
yuzhichang pushed a commit that referenced this pull request Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants