fix(web): enable JSON_OBJECT type support in console UI#2
Conversation
Code Review by Qodo
1. return True in TS
|
| } | ||
| 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
• The function handleJSONSchemaChange returns True (Python boolean) instead of TypeScript true, which will fail compilation under strict TypeScript settings. • This breaks the build and prevents the JSON schema change handler from working as intended. • Fixing this is required to satisfy strict compilation requirements.
Agent prompt
## Issue description
`handleJSONSchemaChange` returns `True`, which is not valid TypeScript and will fail strict compilation.
## Issue Context
This codepath is part of the JSON schema editor behavior and must compile under the repo's strict TS settings.
## Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/index.tsx[131-142]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| 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 json parse 📘 Rule violation ➹ Performance
• const v = JSON.parse(value) is assigned but never used, creating a dead store and avoidable work. • This violates configured maintainability rules and can fail linting (SonarJS no-dead-store), and the single-letter identifier v is not self-documenting. • Remove the unused variable or use it meaningfully with a descriptive name.
Agent prompt
## Issue description
An unused variable `v` is created from `JSON.parse(value)` but never referenced, triggering dead-store lint issues and reducing readability.
## Issue Context
The intent appears to be "validate JSON"; the parsed result does not need to be stored if it is not used.
## 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
| 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. normalizedjsonschema unused 📘 Rule violation ✧ Quality
• normalizedJsonSchema is computed but never used, which is a dead store and can violate SonarJS maintainability rules. • This increases cognitive load and suggests incomplete normalization logic, making future refactors error-prone. • Either use normalizedJsonSchema when building payloadToSave, or remove it entirely.
Agent prompt
## Issue description
`normalizedJsonSchema` is assigned but never used, which violates maintainability lint rules and suggests incomplete normalization.
## Issue Context
The code already constructs `payloadToSave`; it can directly set `json_schema: normalizedJsonSchema` (or remove `normalizedJsonSchema` if unnecessary).
## Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/index.tsx[249-257]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| type: 'object', | ||
| properties: { | ||
| foo: { | ||
| type: 'string', | ||
| }, | ||
| bar: { | ||
| type: 'object', | ||
| properties: { | ||
| sub: { | ||
| type: 'number', | ||
| }, | ||
| }, | ||
| required: [], | ||
| additionalProperties: true, | ||
| }, | ||
| required: [], | ||
| additionalProperties: true, | ||
| }, | ||
| required: [], | ||
| additionalProperties: true, |
There was a problem hiding this comment.
4. jsonconfigplaceholder hardcoded 📘 Rule violation ✓ Correctness
• jsonConfigPlaceHolder is a hardcoded, user-visible placeholder string (schema example) rather than being sourced from i18n translation keys. • If this placeholder is displayed in the UI, it violates the requirement that user-facing strings come from web/i18n/... and are accessed via useTranslation. • Consider moving this placeholder content behind an i18n key (or confirm it is not user-facing and keep it internal).
Agent prompt
## Issue description
A likely user-facing placeholder (`jsonConfigPlaceHolder`) is hardcoded instead of being provided via i18n translation keys.
## Issue Context
The compliance standard requires user-visible text to be managed via `web/i18n/...` and `useTranslation`.
## Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/config.ts[8-30]
- web/app/components/app/configuration/config-var/config-modal/index.tsx[31-33]
ⓘ 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.
5. json_schema can be saved on wrong type 🐞 Bug ✓ Correctness
• After enabling the jsonObject type in the modal, a user can enter a JSON schema, then switch the variable type to a non-jsonObject type. • The modal never clears json_schema on type change, and payloadToSave only removes json_schema when it is empty—so a hidden/stale schema can be persisted alongside non-jsonObject variables. • This violates the local type contract (json_schema is for jsonObject only) and can cause confusing behavior (schema unexpectedly reappears if the user later switches back) and potential backend validation failures.
Agent prompt
### Issue description
`json_schema` can persist and be saved even when the variable type is not `InputVarType.jsonObject`.
### Issue Context
`InputVar.json_schema` is documented as "for jsonObject type" only, but the modal does not clear it when switching away from `jsonObject`, and save normalization only removes it when empty.
### Fix Focus Areas
- web/app/components/app/configuration/config-var/config-modal/index.tsx[187-205]
- 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 agentic-review-benchmarks#2