fix(web): enable JSON_OBJECT type support in console UI#127
Conversation
Code Review by Qodo
1. return True in TS
|
| 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.
1. return true in ts 📘 Rule violation ✓ Correctness
• handleJSONSchemaChange returns True, which is not a valid TypeScript boolean literal (should be true). • This will cause a TypeScript compile/runtime failure when the callback executes, violating strict compilation expectations.
Agent prompt
## Issue description
`handleJSONSchemaChange` returns `True`, which is invalid TypeScript and breaks strict compilation.
## Issue Context
This callback is part of the config modal JSON schema editor flow; returning an invalid identifier will fail build/typecheck.
## Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/index.tsx[130-143]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| 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.
2. Unused v from json.parse 📘 Rule violation ✓ Correctness
• const v = JSON.parse(value) is assigned but never used, creating a dead store. • This violates the configured SonarJS lint expectations and can fail CI/lint checks.
Agent prompt
## Issue description
Dead store: `v` is assigned from `JSON.parse(value)` but never used.
## Issue Context
This triggers SonarJS `no-dead-store` / unused-var style failures in production frontend code.
## Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/index.tsx[136-139]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| const jsonSchemaValue = tempPayload.json_schema | ||
| const isSchemaEmpty = isJsonSchemaEmpty(jsonSchemaValue) | ||
| const normalizedJsonSchema = isSchemaEmpty ? undefined : jsonSchemaValue | ||
|
|
||
| // if the input type is jsonObject and the schema is empty as determined by `isJsonSchemaEmpty`, | ||
| // remove the `json_schema` field from the payload by setting its value to `undefined`. | ||
| const payloadToSave = isSchemaEmpty | ||
| ? { ...tempPayload, json_schema: undefined } | ||
| : tempPayload |
There was a problem hiding this comment.
3. Unused normalizedjsonschema variable 📘 Rule violation ✓ Correctness
• normalizedJsonSchema is computed but never used, which is a dead store/unnecessary local. • This can violate SonarJS lint rules (and potentially noUnusedLocals), causing build/lint failures.
Agent prompt
## Issue description
Dead store: `normalizedJsonSchema` is computed but never used.
## Issue Context
This can violate SonarJS lint rules and/or TypeScript unused locals checks.
## Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/index.tsx[248-257]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Benchmark PR from qodo-benchmark#439