fix(web): enable JSON_OBJECT type support in console UI#153
Conversation
Review Summary by QodoFix JSON_OBJECT type support and schema validation in console UI
WalkthroughsDescription• Fixed JSON_OBJECT type support by correcting schema structure handling • Removed automatic schema wrapping to accept full JSON schema objects • Added validation for JSON schema format and object type requirement • Updated JSON schema placeholder to demonstrate correct structure • Added comprehensive error messages across 24 language translations Diagramflowchart LR
A["JSON Schema Input"] --> B["Validation Logic"]
B --> C["Check if Empty"]
C -->|Empty| D["Set to undefined"]
C -->|Not Empty| E["Parse JSON"]
E --> F["Verify Type is object"]
F -->|Valid| G["Save Schema"]
F -->|Invalid| H["Show Error Message"]
D --> I["Payload Saved"]
G --> I
File Changes1. web/app/components/app/configuration/config-var/config-modal/config.ts
|
Code Review by Qodo
1. return True breaks TypeScript
|
| } | ||
| handlePayloadChange('json_schema')(JSON.stringify(res, null, 2)) | ||
| handlePayloadChange('json_schema')(value) | ||
| return True |
There was a problem hiding this comment.
1. return true breaks typescript 📘 Rule violation ✓ Correctness
The function returns True (Python-style) instead of TypeScript true, which will cause a runtime/compile error under strict TypeScript compilation. This can break the JSON schema editing flow in the config modal.
Agent Prompt
## Issue description
TypeScript code returns `True` (invalid identifier) instead of `true`, which breaks strict compilation.
## Issue Context
This occurs in the `handleJSONSchemaChange` callback in the config modal.
## Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/index.tsx[136-142]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| return null | ||
| } | ||
| try { | ||
| const v = JSON.parse(value) |
There was a problem hiding this comment.
2. Dead store v variable 📘 Rule violation ⛯ Reliability
A parsed JSON value is assigned to v but never used, which violates configured maintainability rules and may fail linting/quality gates. This adds unnecessary code and can trigger SonarJS no-dead-store errors.
Agent Prompt
## Issue description
`const v = JSON.parse(value)` is introduced but `v` is never used, which can violate SonarJS `no-dead-store` and other lint rules.
## Issue Context
The code appears to parse only to validate JSON; it can parse without storing the result.
## Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/index.tsx[136-140]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| const jsonSchemaStr = useMemo(() => { | ||
| const isJsonObject = type === InputVarType.jsonObject | ||
| if (!isJsonObject || !tempPayload.json_schema) | ||
| return '' | ||
| try { | ||
| return JSON.stringify(JSON.parse(tempPayload.json_schema).properties, null, 2) | ||
| return JSON.stringify(JSON.parse(tempPayload.json_schema), null, 2) | ||
| } | ||
| catch { | ||
| return '' |
There was a problem hiding this comment.
3. Stale jsonschemastr memo 🐞 Bug ✓ Correctness
jsonSchemaStr’s useMemo reads type but only depends on tempPayload.json_schema, so it can return a value computed under an old type. This can show an empty schema editor when switching to jsonObject while an existing json_schema string is already present.
Agent Prompt
### Issue description
`jsonSchemaStr` uses `type` but does not include it in the `useMemo` dependency list, allowing stale memoized values when `type` changes without `json_schema` changing.
### Issue Context
`handleTypeChange` updates `tempPayload.type` without clearing `json_schema`, so the missing dependency is observable in the UI.
### Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/index.tsx[81-91]
- web/app/components/app/configuration/config-var/config-modal/index.tsx[187-205]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Benchmark PR from agentic-review-benchmarks#2