fix(web): enable JSON_OBJECT type support in console UI#15
Conversation
| } | ||
| handlePayloadChange('json_schema')(JSON.stringify(res, null, 2)) | ||
| handlePayloadChange('json_schema')(value) | ||
| return True |
There was a problem hiding this comment.
🔴 Python-style True used instead of JavaScript true causes ReferenceError
The handleJSONSchemaChange function returns True (Python-style boolean) instead of true (JavaScript/TypeScript boolean), which will cause a ReferenceError: True is not defined at runtime.
Click to expand
Bug Details
At line 139, the code returns True after successfully parsing JSON:
try {
const v = JSON.parse(value)
handlePayloadChange('json_schema')(value)
return True // BUG: should be `true`
}In JavaScript/TypeScript, the boolean literal is lowercase true, not True. The identifier True is not defined anywhere in the codebase, so this will throw a ReferenceError when the function is called with valid JSON input.
Impact
When a user enters valid JSON in the JSON Schema editor for a JSON Object variable type, the application will crash with:
ReferenceError: True is not defined
This completely breaks the JSON_OBJECT type support feature that this PR is trying to enable.
Expected vs Actual
- Expected: The function should return
trueto indicate successful JSON parsing - Actual: The function returns
Truewhich is undefined, causing a runtime error
Recommendation: Change return True to return true (lowercase)
Was this helpful? React with 👍 or 👎 to provide feedback.
Benchmark PR from qodo-benchmark#439