From d8d298851205c744e964f13e4821b7daa5cbb32c Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Tue, 17 Dec 2024 23:10:10 +0100 Subject: [PATCH] refactor(agents/v1): reorganized variables and error logging --- api/server/controllers/agents/v1.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/api/server/controllers/agents/v1.js b/api/server/controllers/agents/v1.js index 7338307d030..26a92deee16 100644 --- a/api/server/controllers/agents/v1.js +++ b/api/server/controllers/agents/v1.js @@ -191,6 +191,7 @@ const updateAgentHandler = async (req, res) => { const duplicateAgentHandler = async (req, res) => { const { id } = req.params; const { id: userId } = req.user; + const sensitiveFields = ['api_key', 'oauth_client_id', 'oauth_client_secret']; try { const agent = await getAgent({ id }); @@ -220,8 +221,6 @@ const duplicateAgentHandler = async (req, res) => { const actionsData = []; const originalActions = await getActions({ agent_id: id }, true); - const sensitiveFields = ['api_key', 'oauth_client_id', 'oauth_client_secret']; - if (originalActions?.length) { const newActions = await Promise.all( originalActions.map(async (action) => { @@ -272,9 +271,7 @@ const duplicateAgentHandler = async (req, res) => { actions: filteredActions, }); } catch (error) { - logger.error('[/Agents/:id/duplicate] Error duplicating Agent:', { - error, - }); + logger.error('[/Agents/:id/duplicate] Error duplicating Agent:', error); res.status(500).json({ error: error.message }); }