Skip to content

Commit 09db83e

Browse files
authored
[BUGFIX] Fix a "null"-rendering issue (#1575)
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Fixes null handling in `ParsedResponseRender.tsx` and updates configuration files for better formatting and conditions. > > - **Bugfix in `ParsedResponseRender.tsx`**: > - Fixes issue where `null` response was not handled, now returns `null` instead of undefined. > - Handles cases where `parsedResponseObj` is `null` or not an object by rendering `RenderPromptPart`. > - **Configuration Changes**: > - Adds condition `if: github.event_name == 'release'` to `build-cli` job in `primary.yml`. > - Corrects JSON formatting in `launch.json` by adding missing commas. > - Updates `tsconfig.build.json` to include `src/**/*` and removes `exclude` section. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 050ee47. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
1 parent 4153bd3 commit 09db83e

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

.github/workflows/primary.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ jobs:
142142
cd integ-tests/python
143143
./run_tests.sh
144144
build-cli:
145+
if: github.event_name == 'release'
145146
strategy:
146147
fail-fast: false
147148
matrix:

typescript/.vscode/launch.json

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"env": {
1919
"VSCODE_DEBUG_MODE": "true"
20-
}
20+
},
2121
},
2222
{
2323
"type": "node",
@@ -26,7 +26,9 @@
2626
"port": 6009,
2727
"restart": true,
2828
"timeout": 10000,
29-
"outFiles": ["${workspaceFolder}/vscode-ext/packages/language-server/dist/**/*.js"]
29+
"outFiles": [
30+
"${workspaceFolder}/vscode-ext/packages/language-server/dist/**/*.js"
31+
]
3032
},
3133
{
3234
"name": "Run Language Server Tests",
@@ -48,7 +50,9 @@
4850
"runtimeExecutable": null,
4951
"runtimeArgs": [],
5052
"env": {},
51-
"outFiles": ["${workspaceRoot}/vscode-ext/packages/language-server/dist/src/__test__/**/*.js"],
53+
"outFiles": [
54+
"${workspaceRoot}/vscode-ext/packages/language-server/dist/src/__test__/**/*.js"
55+
],
5256
"preLaunchTask": "npm: watch"
5357
},
5458
{
@@ -61,13 +65,18 @@
6165
"--extensionTestsPath=${workspaceFolder}/vscode-ext/packages/vscode/dist/src/__test__/index",
6266
"${workspaceFolder}/vscode-ext/packages/vscode/fixtures"
6367
],
64-
"outFiles": ["${workspaceFolder}/vscode-ext/packages/vscode/dist/src/__test__/**/*.js"]
68+
"outFiles": [
69+
"${workspaceFolder}/vscode-ext/packages/vscode/dist/src/__test__/**/*.js"
70+
]
6571
}
6672
],
6773
"compounds": [
6874
{
6975
"name": "VS Code + Language Server",
70-
"configurations": ["Launch VS Code extension", "Attach to Server"]
76+
"configurations": [
77+
"Launch VS Code extension",
78+
"Attach to Server"
79+
]
7180
}
7281
]
73-
}
82+
}

typescript/common/tsconfig.build.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
// This tsconfig just checks the compilation is accurate since
33
// tsup seems to miss some type errors.
44
"extends": "./tsconfig.json",
5-
"exclude": [
6-
"node_modules",
7-
"**/*.test.ts",
8-
"gloo"
5+
"include": [
6+
"src/**/*",
97
],
108
"compilerOptions": {
11-
"noEmit": true,
129
"emitDeclarationOnly": false
1310
}
1411
}

typescript/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/components/ParsedResponseRender.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ const ParsedResponseRender = ({ response }: { response: string | undefined }) =>
4343
const { theme } = useTheme()
4444

4545
if (!response) {
46-
return
46+
return null
4747
}
4848

4949
let parsedResponseObj
5050
try {
51-
parsedResponseObj = JSON.parse(response ?? '{}')
51+
parsedResponseObj = JSON.parse(response)
52+
if (parsedResponseObj === null || typeof parsedResponseObj !== 'object') {
53+
return <RenderPromptPart text={response} />
54+
}
5255
} catch (e) {
5356
parsedResponseObj = response
5457
}
@@ -62,7 +65,7 @@ const ParsedResponseRender = ({ response }: { response: string | undefined }) =>
6265
<ScrollArea className='pr-2 w-full text-xs' type='always'>
6366
<JsonView
6467
className='p-1 w-full rounded-md'
65-
value={parsedResponseObj}
68+
value={parsedResponseObj || {}}
6669
collapsed={false}
6770
enableClipboard={true}
6871
displayDataTypes={false}

0 commit comments

Comments
 (0)