Skip to content

Commit aad95cb

Browse files
committed
handle malformed guardrails and add stack trace to chat completions handler
1 parent d56830b commit aad95cb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/handlers/chatCompletionsHandler.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export async function chatCompletionsHandler(c: Context): Promise<Response> {
3030

3131
return tryTargetsResponse;
3232
} catch (err: any) {
33-
console.error('chatCompletionsHandler error: ', err);
33+
console.error(
34+
`chatCompletionsHandler error: ${err.message} \n\n stackTrace: ${err.stack}`
35+
);
3436
let statusCode = 500;
3537
let errorMessage = 'Something went wrong';
3638

src/handlers/handlerUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export function convertHooksShorthand(
260260

261261
// Now, add all the checks to the checks array
262262
hooksObject.checks = Object.keys(hook).map((key) => {
263-
const id = hook[key].id;
263+
const id = hook[key].id ?? key;
264264
return {
265265
id: id.includes('.') ? id : `default.${id}`,
266266
parameters: hook[key],

0 commit comments

Comments
 (0)