Skip to content

Commit

Permalink
fix: bypass real error info from backend (#92)
Browse files Browse the repository at this point in the history
* feat: throw error from backend

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize logic

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
  • Loading branch information
SuZhou-Joe authored Jan 5, 2024
1 parent d4290b0 commit 4c0386b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
5 changes: 1 addition & 4 deletions server/routes/chat_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ export function registerChatRoutes(router: IRouter, routeOptions: RoutesOptions)
});
} catch (error) {
context.assistant_plugin.logger.error(error);
const sessionId = outputs?.memoryId || sessionIdInRequestBody;
if (!sessionId) {
return response.custom({ statusCode: error.statusCode || 500, body: error.message });
}
return response.custom({ statusCode: error.statusCode || 500, body: error.message });
}

/**
Expand Down
24 changes: 10 additions & 14 deletions server/routes/send_message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('send_message route when rootAgentName is provided', () => {
`);
});

it('return successfully when requestLLM throws an error but conversation id provided', async () => {
it('throw error when requestLLM throws an error', async () => {
mockOllyChatService.requestLLM.mockImplementationOnce(() => {
throw new Error('something went wrong');
});
Expand All @@ -209,21 +209,17 @@ describe('send_message route when rootAgentName is provided', () => {
},
},
sessionId: 'foo',
})) as ResponseObject;
})) as Boom;
expect(mockedLogger.error).toBeCalledWith(new Error('something went wrong'));
expect(result.source).toMatchInlineSnapshot(`
expect(result.output).toMatchInlineSnapshot(`
Object {
"interactions": Array [
Object {
"conversation_id": "foo",
"create_time": "create_time",
"input": "foo",
"interaction_id": "interaction_id",
"response": "bar",
},
],
"messages": Array [],
"sessionId": "foo",
"headers": Object {},
"payload": Object {
"error": "Internal Server Error",
"message": "something went wrong",
"statusCode": 500,
},
"statusCode": 500,
}
`);
});
Expand Down

0 comments on commit 4c0386b

Please sign in to comment.