fix(web): enable JSON_OBJECT type support in console UI#2
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request enables JSON_OBJECT type support in the console UI by modifying how JSON schemas are stored and validated for input variables. The changes remove a wrapper structure that was previously added around schema properties and instead store the full JSON schema directly.
Changes:
- Added validation for JSON Schema inputs with two new error messages (invalid JSON and non-object type)
- Removed the
isSupportJSONflag to enable JSON Object type support for all non-basic apps - Updated JSON schema handling to store the complete schema structure instead of wrapping only the properties
- Added translations for the new error messages across 22 language files
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| web/i18n/*/app-debug.json (22 files) | Added translations for two new error messages: jsonSchemaInvalid and jsonSchemaMustBeObject |
| web/app/components/app/configuration/config-var/config-modal/index.tsx | Modified JSON schema handling logic, removed feature flag, added validation for JSON object type, and implemented empty schema normalization |
| web/app/components/app/configuration/config-var/config-modal/config.ts | Updated placeholder structure to show complete JSON schema format instead of just properties |
Comments suppressed due to low confidence (1)
web/app/components/app/configuration/config-var/config-modal/index.tsx:91
- The useMemo dependency array is missing 'type' as a dependency. The computed value 'jsonSchemaStr' depends on both 'type' and 'tempPayload.json_schema', but only the latter is included in the dependency array. This could lead to stale values if the type changes.
const jsonSchemaStr = useMemo(() => {
const isJsonObject = type === InputVarType.jsonObject
if (!isJsonObject || !tempPayload.json_schema)
return ''
try {
return JSON.stringify(JSON.parse(tempPayload.json_schema), null, 2)
}
catch {
return ''
}
}, [tempPayload.json_schema])
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| handlePayloadChange('json_schema')(JSON.stringify(res, null, 2)) | ||
| handlePayloadChange('json_schema')(value) | ||
| return True |
There was a problem hiding this comment.
The value 'True' should be 'true' in JavaScript/TypeScript. JavaScript uses lowercase 'true' as a boolean literal, not Python's capitalized 'True'.
| return True | |
| return true |
| const handleConfirm = () => { | ||
| const jsonSchemaValue = tempPayload.json_schema | ||
| const isSchemaEmpty = isJsonSchemaEmpty(jsonSchemaValue) | ||
| const normalizedJsonSchema = isSchemaEmpty ? undefined : jsonSchemaValue |
There was a problem hiding this comment.
The variable 'normalizedJsonSchema' is declared but never used. It can be removed since the same logic is handled by 'payloadToSave' variable on the next lines.
| const normalizedJsonSchema = isSchemaEmpty ? undefined : jsonSchemaValue |
Benchmark PR from agentic-review-benchmarks#2