From 3680378e545665b6091f8799099fe7abed3de4ff Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 1 Apr 2023 17:45:12 +0800 Subject: [PATCH] fix(nocodb): return error for hook test --- .../nocodb/src/lib/controllers/hook.ctl.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/lib/controllers/hook.ctl.ts b/packages/nocodb/src/lib/controllers/hook.ctl.ts index bf909e2ffc..5786ad0f74 100644 --- a/packages/nocodb/src/lib/controllers/hook.ctl.ts +++ b/packages/nocodb/src/lib/controllers/hook.ctl.ts @@ -46,11 +46,21 @@ export async function hookUpdate( } export async function hookTest(req: Request, res: Response) { - await hookService.hookTest({ - hookTest: req.body, - tableId: req.params.tableId, - }); - res.json({ msg: 'The hook has been tested successfully' }); + try { + await hookService.hookTest({ + hookTest: { + ...req.body, + payload: { + ...req.body.payload, + user: (req as any)?.user, + }, + }, + tableId: req.params.tableId, + }); + res.json({ msg: 'The hook has been tested successfully' }); + } catch (e) { + throw e; + } } export async function tableSampleData(req: Request, res: Response) {