fix(web): enable JSON_OBJECT type support in console UI - #51
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enables JSON_OBJECT type support in the console UI by adding validation for JSON schemas and updating internationalization strings across 23 languages.
Changes:
- Added JSON schema validation to ensure schemas are valid JSON and have type "object"
- Updated JSON schema handling to store the complete schema object instead of just properties
- Added error messages in 23 languages for invalid JSON schemas
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| web/i18n/*/app-debug.json (23 files) | Added two new error message keys for JSON schema validation in all supported languages |
| web/app/components/app/configuration/config-var/config-modal/index.tsx | Implemented JSON schema validation, updated schema storage format, and added validation checks in handleConfirm |
| web/app/components/app/configuration/config-var/config-modal/config.ts | Updated placeholder to show complete JSON Schema structure with top-level type field |
| else if (type === InputVarType.jsonObject) { | ||
| if (!isSchemaEmpty && typeof jsonSchemaValue === 'string') { | ||
| try { | ||
| const schema = JSON.parse(jsonSchemaValue) | ||
| if (schema?.type !== 'object') { | ||
| Toast.notify({ type: 'error', message: t('variableConfig.errorMsg.jsonSchemaMustBeObject', { ns: 'appDebug' }) }) | ||
| return | ||
| } | ||
| } | ||
| catch { | ||
| Toast.notify({ type: 'error', message: t('variableConfig.errorMsg.jsonSchemaInvalid', { ns: 'appDebug' }) }) | ||
| return | ||
| } | ||
| } | ||
| onConfirm(payloadToSave, moreInfo) |
There was a problem hiding this comment.
The new JSON object validation functionality (lines 310-324) and JSON schema handling (lines 131-144, 237-257) are not covered by tests. According to the project's testing guidelines, behavior in new or updated code should have adequate test coverage. The component test file exists at 'web/app/components/app/configuration/config-var/index.spec.tsx', but there are no tests for the jsonObject input type and its validation logic.
| 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 assigned but never used. It appears to be redundant since the same logic is already applied when creating 'payloadToSave' on line 255-257. This variable should be removed to improve code maintainability.
| const normalizedJsonSchema = isSchemaEmpty ? undefined : jsonSchemaValue |
| } | ||
| handlePayloadChange('json_schema')(JSON.stringify(res, null, 2)) | ||
| handlePayloadChange('json_schema')(value) | ||
| return True |
There was a problem hiding this comment.
JavaScript/TypeScript uses lowercase 'true' for the boolean literal, not 'True' (which is Python syntax). This will cause a ReferenceError at runtime since 'True' is not defined.
| return True | |
| return true |
Benchmark PR from qodo-benchmark#439