Skip to content

Commit

Permalink
refactor(agents/v1): reorganized variables and error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
berry-13 committed Dec 17, 2024
1 parent 880c4a0 commit d8d2988
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions api/server/controllers/agents/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 });
}
Expand Down

0 comments on commit d8d2988

Please sign in to comment.