fix(web): enable JSON_OBJECT type support in console UI#15
Conversation
WalkthroughThis PR refactors JSON schema handling in the config modal component by consolidating the JSON placeholder structure, removing the isSupportJSON dependency, and adding validation for JSON schemas. New error messages are introduced across 22 language files to support schema validation feedback. Changes
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@web/app/components/app/configuration/config-var/config-modal/index.tsx`:
- Around line 131-140: The return value in the JSON parse branch uses the
Python-style identifier "True" which is undefined in JS/TS; update the return
statement in the function handling the json_schema field (the branch that parses
value with JSON.parse and calls handlePayloadChange('json_schema')) to return
the boolean literal true instead of True, and ensure the function's return type
matches a boolean or null as intended (check the uses of isEmpty and
handlePayloadChange to confirm expected type).
🧹 Nitpick comments (1)
web/app/components/app/configuration/config-var/config-modal/index.tsx (1)
81-91: Addtypeto theuseMemodeps to avoid stale schema text.
When users toggle from a non-JSON type back tojsonObject,jsonSchemaStrcan remain cached as empty becausetypeisn’t a dependency.♻️ Suggested fix
- }, [tempPayload.json_schema]) + }, [tempPayload.json_schema, type])
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (24)
web/app/components/app/configuration/config-var/config-modal/config.tsweb/app/components/app/configuration/config-var/config-modal/index.tsxweb/i18n/ar-TN/app-debug.jsonweb/i18n/de-DE/app-debug.jsonweb/i18n/en-US/app-debug.jsonweb/i18n/es-ES/app-debug.jsonweb/i18n/fa-IR/app-debug.jsonweb/i18n/fr-FR/app-debug.jsonweb/i18n/hi-IN/app-debug.jsonweb/i18n/id-ID/app-debug.jsonweb/i18n/it-IT/app-debug.jsonweb/i18n/ja-JP/app-debug.jsonweb/i18n/ko-KR/app-debug.jsonweb/i18n/pl-PL/app-debug.jsonweb/i18n/pt-BR/app-debug.jsonweb/i18n/ro-RO/app-debug.jsonweb/i18n/ru-RU/app-debug.jsonweb/i18n/sl-SI/app-debug.jsonweb/i18n/th-TH/app-debug.jsonweb/i18n/tr-TR/app-debug.jsonweb/i18n/uk-UA/app-debug.jsonweb/i18n/vi-VN/app-debug.jsonweb/i18n/zh-Hans/app-debug.jsonweb/i18n/zh-Hant/app-debug.json
🧰 Additional context used
🧬 Code graph analysis (1)
web/app/components/app/configuration/config-var/config-modal/index.tsx (1)
web/scripts/auto-gen-i18n.js (1)
trimmed(149-149)
🔇 Additional comments (25)
web/i18n/pl-PL/app-debug.json (1)
309-310: LGTM — translations are clear and consistent.web/i18n/pt-BR/app-debug.json (1)
309-310: LGTM — translations read well and match the new validation messages.web/i18n/ro-RO/app-debug.json (1)
309-310: Translations look good.Clear, user‑friendly error messages consistent with JSON Schema validation context.
web/i18n/zh-Hant/app-debug.json (1)
309-310: LGTM!The new i18n entries for JSON Schema validation error messages are correctly implemented:
- Keys follow the existing
variableConfig.errorMsg.*naming convention.- Traditional Chinese translations are accurate and use proper punctuation (「」for quoted terms).
- JSON syntax is valid.
web/i18n/uk-UA/app-debug.json (1)
309-310: LGTM!The new Ukrainian translation keys for JSON Schema validation errors are correctly formatted and follow the existing naming conventions. The translations are grammatically appropriate, and the escaped quotes in
jsonSchemaMustBeObjectare properly handled.web/i18n/th-TH/app-debug.json (1)
309-310: LGTM!The new Thai translations for JSON Schema validation error messages are correctly added. The keys follow the existing naming convention, the JSON syntax is valid with properly escaped quotes, and the translations accurately convey the intended validation feedback.
web/i18n/ru-RU/app-debug.json (1)
309-310: LGTM!The new Russian localization entries for JSON Schema validation errors are well-formed and consistent with the existing structure.
web/i18n/ar-TN/app-debug.json (1)
309-310: LGTM!The Arabic localization entries are correctly formatted and consistent with the PR's changes across other locales.
web/i18n/en-US/app-debug.json (1)
309-310: LGTM!The base English localization entries for JSON Schema validation are clear and appropriately descriptive for the validation scenarios.
web/i18n/vi-VN/app-debug.json (1)
309-310: LGTM!The Vietnamese localization entries are correctly formatted and consistent with the changes across other locales.
web/i18n/tr-TR/app-debug.json (1)
309-310: LGTM!The Turkish localization entries are correctly formatted with appropriate translations.
web/i18n/fa-IR/app-debug.json (1)
309-310: LGTM!The Persian (Farsi) localization entries are correctly formatted and consistent with the PR's changes.
web/i18n/it-IT/app-debug.json (1)
309-310: LGTM — Italian JSON schema validation messages added.
Strings are clear and aligned with the new validation rules.web/i18n/sl-SI/app-debug.json (1)
309-310: LGTM — Slovenian JSON schema validation messages added.
No issues found with the new strings.web/i18n/de-DE/app-debug.json (1)
309-310: LGTM — German JSON schema validation messages added.
Looks consistent with the validation behavior.web/i18n/hi-IN/app-debug.json (1)
309-310: LGTM — Hindi JSON schema validation messages added.
Strings align with the new validation flow.web/i18n/ko-KR/app-debug.json (1)
309-310: LGTM — Korean JSON schema validation messages added.
No issues with the new localized strings.web/i18n/zh-Hans/app-debug.json (1)
309-310: LGTM — Simplified Chinese JSON schema validation messages added.
Clear and consistent with the new validation rules.web/i18n/fr-FR/app-debug.json (1)
309-310: LGTM — FR validation strings added.
These additions match the new JSON schema validation flow.web/i18n/ja-JP/app-debug.json (1)
309-310: LGTM — JA validation strings added.
These additions match the new JSON schema validation flow.web/app/components/app/configuration/config-var/config-modal/config.ts (1)
8-27: LGTM — placeholder schema consolidated correctly.
The JSON Schema placeholder now reflects an object-based schema as intended.web/i18n/id-ID/app-debug.json (1)
309-310: LGTM — ID validation strings added.
These additions match the new JSON schema validation flow.web/i18n/es-ES/app-debug.json (1)
309-310: LGTM — ES validation strings added.
These additions match the new JSON schema validation flow.web/app/components/app/configuration/config-var/config-modal/index.tsx (2)
179-184: LGTM — JSON option gating looks correct for non-basic apps.
This simplifies the selection logic while keeping the JSON type behind the app mode gate.
237-327: LGTM — json_schema normalization and validation are solid.
Dropping emptyjson_schemaand validating object-type schemas should improve UX and data hygiene.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| const isEmpty = value == null || value.trim() === '' | ||
| if (isEmpty) { | ||
| handlePayloadChange('json_schema')(undefined) | ||
| return null | ||
| } | ||
| try { | ||
| const v = JSON.parse(value) | ||
| const res = { | ||
| ...jsonObjectWrap, | ||
| properties: v, | ||
| } | ||
| handlePayloadChange('json_schema')(JSON.stringify(res, null, 2)) | ||
| handlePayloadChange('json_schema')(value) | ||
| return True | ||
| } |
There was a problem hiding this comment.
Fix True → true (build/runtime breaker).
Line 139 uses True, which is undefined in TS/JS and will fail compilation or throw at runtime.
🐛 Proposed fix
- return True
+ return true📝 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.
| const isEmpty = value == null || value.trim() === '' | |
| if (isEmpty) { | |
| handlePayloadChange('json_schema')(undefined) | |
| return null | |
| } | |
| try { | |
| const v = JSON.parse(value) | |
| const res = { | |
| ...jsonObjectWrap, | |
| properties: v, | |
| } | |
| handlePayloadChange('json_schema')(JSON.stringify(res, null, 2)) | |
| handlePayloadChange('json_schema')(value) | |
| return True | |
| } | |
| const isEmpty = value == null || value.trim() === '' | |
| if (isEmpty) { | |
| handlePayloadChange('json_schema')(undefined) | |
| return null | |
| } | |
| try { | |
| const v = JSON.parse(value) | |
| handlePayloadChange('json_schema')(value) | |
| return true | |
| } |
🤖 Prompt for AI Agents
In `@web/app/components/app/configuration/config-var/config-modal/index.tsx`
around lines 131 - 140, The return value in the JSON parse branch uses the
Python-style identifier "True" which is undefined in JS/TS; update the return
statement in the function handling the json_schema field (the branch that parses
value with JSON.parse and calls handlePayloadChange('json_schema')) to return
the boolean literal true instead of True, and ensure the function's return type
matches a boolean or null as intended (check the uses of isEmpty and
handlePayloadChange to confirm expected type).
Benchmark PR from qodo-benchmark#439
Summary by CodeRabbit
Release Notes
New Features
Localization
✏️ Tip: You can customize this high-level summary in your review settings.