From 27799e671a7c4130d19b48198d74f158168aedf2 Mon Sep 17 00:00:00 2001 From: Aditya Mane Date: Sat, 13 Jun 2026 21:03:52 +0530 Subject: [PATCH 1/3] invalid uuid check is returning a plain object instead of sending HTTP response --- src/api/controllers/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/controllers/config.js b/src/api/controllers/config.js index 97cf7dcf36..a08d132cb2 100644 --- a/src/api/controllers/config.js +++ b/src/api/controllers/config.js @@ -41,7 +41,7 @@ const getConfigPool = async (req, res) => { const valid = ids.map((id) => validator.isUUID(id)).reduce((a, b) => a + b, 0) === ids.length; - if (!valid) return { status: 'invalid uuid parameter' }; + if (!valid) return res.status(400).json({ status: 'invalid uuid parameter' }); const query = ` SELECT From 3b23184b3d4d6570d9511f42c36b8d865ad690c3 Mon Sep 17 00:00:00 2001 From: Aditya Mane Date: Sat, 13 Jun 2026 21:16:15 +0530 Subject: [PATCH 2/3] properly handle errors in config controller suggested by coderabbit --- src/api/controllers/config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/controllers/config.js b/src/api/controllers/config.js index a08d132cb2..29fa555917 100644 --- a/src/api/controllers/config.js +++ b/src/api/controllers/config.js @@ -28,7 +28,7 @@ const getDistinctID = async (req, res) => { const response = await conn.query(query); if (!response) { - return new AppError(`Couldn't get data`, 404); + throw new AppError(`Couldn't get data`, 404); } res.status(200).json(response); @@ -54,7 +54,7 @@ const getConfigPool = async (req, res) => { const response = await conn.query(query, { configIDs: ids }); if (!response) { - return new AppError(`Couldn't get data`, 404); + throw new AppError(`Couldn't get data`, 404); } res.status(200).json({ @@ -79,7 +79,7 @@ const getAllPools = async (req, res) => { const response = await conn.query(query); if (!response) { - return new AppError(`Couldn't get data`, 404); + throw new AppError(`Couldn't get data`, 404); } res.status(200).json(response); From 9abfffd234f8f8561d18e37c3bd67eb77fc5d344 Mon Sep 17 00:00:00 2001 From: Aditya Mane Date: Sat, 13 Jun 2026 23:44:13 +0530 Subject: [PATCH 3/3] fix(app): error handler was ignoring AppError statusCode and always returning 500 with HTML --- src/api/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/app.js b/src/api/app.js index a413ed0870..dfe216e2b4 100644 --- a/src/api/app.js +++ b/src/api/app.js @@ -54,8 +54,8 @@ app.use('/', [yieldRoutes, config, median, perp, enriched, lsd, pools]); function errorHandler (err, req, res, next) { console.log(err) - res.status(500) - res.render('error', { error: err }) + const statusCode = err.statusCode ?? 500 + res.status(statusCode).json({ status: err.status ?? 'error', message: err.message }) } app.use(errorHandler)