fix(web): enable JSON_OBJECT type support in console UI#2
Conversation
📝 WalkthroughWalkthroughThis PR enhances JSON schema validation for configuration variables by restructuring the schema placeholder format, adding validation logic to the config modal for JSON schema inputs, and providing localized error messages across 20+ language packs. Changes
Sequence DiagramsequenceDiagram
participant User
participant ConfigModal as Config Modal Component
participant Validator as Validation Logic
participant Payload as Payload Handler
User->>ConfigModal: Input JSON Schema string
ConfigModal->>Validator: Check if input is empty
alt Empty Input
Validator->>Payload: Clear json_schema (set undefined)
else Non-Empty Input
Validator->>Validator: Parse JSON & validate format
alt Invalid JSON
Validator->>ConfigModal: Emit jsonSchemaInvalid error
else Valid JSON
Validator->>Validator: Check type === 'object'
alt Type Not Object
Validator->>ConfigModal: Emit jsonSchemaMustBeObject error
else Type Is Object
Validator->>Payload: Include json_schema in payload
end
end
end
Payload->>User: Save configuration with validated schema
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 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
🧪 Generate unit tests (beta)
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. 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 code in the JSON schema handling block uses the
undefined identifier "True" which will throw a ReferenceError; update the return
value in the try block to the JavaScript boolean "true" (inside the function
handling JSON parsing where isEmpty is computed and
handlePayloadChange('json_schema') is called) and ensure the rest of the logic
(JSON.parse(v) usage and handlePayloadChange invocation) remains unchanged so
successful parses return true instead of True.
| 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 to avoid runtime ReferenceError.
True is undefined in JS/TS and will throw, breaking JSON schema edits.
🛠️ 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 code in the JSON schema handling block uses the
undefined identifier "True" which will throw a ReferenceError; update the return
value in the try block to the JavaScript boolean "true" (inside the function
handling JSON parsing where isEmpty is computed and
handlePayloadChange('json_schema') is called) and ensure the rest of the logic
(JSON.parse(v) usage and handlePayloadChange invocation) remains unchanged so
successful parses return true instead of True.
Benchmark PR from agentic-review-benchmarks#2
Summary by CodeRabbit
New Features
Localization
✏️ Tip: You can customize this high-level summary in your review settings.