Skip to content

Commit c584ad9

Browse files
authored
chore(compass-query-bar): update ai backend response parsing COMPASS-6986 (#4601)
1 parent 9e032ba commit c584ad9

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

packages/compass-query-bar/src/modules/ai-query-request.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ describe('#runFetchAIQuery', function () {
4343
expect(requests[0].req.url).to.equal('/ai/api/v1/mql-query');
4444

4545
expect(response).to.deep.equal({
46-
query: {
47-
find: {
48-
test: 'pineapple',
46+
content: {
47+
query: {
48+
find: {
49+
test: 'pineapple',
50+
},
4951
},
5052
},
5153
});

packages/compass-query-bar/src/stores/ai-query-reducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ export const runAIQuery = (
106106

107107
let query;
108108
try {
109-
if (!jsonResponse?.query) {
109+
if (!jsonResponse?.content?.query) {
110110
throw new Error(
111111
'No query returned. Please try again with a different prompt.'
112112
);
113113
}
114114

115-
query = jsonResponse.query;
115+
query = jsonResponse?.content?.query;
116116
} catch (err: any) {
117117
dispatch({
118118
type: AIQueryActionTypes.AIQueryFailed,

packages/compass-query-bar/test/create-mock-ai-endpoint.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ export async function startMockAIServer(
1111
sendError?: boolean;
1212
} = {
1313
response: {
14-
query: {
15-
find: {
16-
test: 'pineapple',
14+
content: {
15+
query: {
16+
find: {
17+
test: 'pineapple',
18+
},
1719
},
1820
},
1921
},

0 commit comments

Comments
 (0)