From 8a87277fe6231ef3654b9ddc8c35e7c500e2b4b6 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Wed, 13 Dec 2023 18:07:39 -0500 Subject: [PATCH 1/2] parse bot not found in agent --- cli/packages/api/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/packages/api/api.go b/cli/packages/api/api.go index 305df6e46..1ae0c5d60 100644 --- a/cli/packages/api/api.go +++ b/cli/packages/api/api.go @@ -481,12 +481,12 @@ func CallGetRawSecretsV3(httpClient *resty.Client, request GetRawSecretsV3Reques return GetRawSecretsV3Response{}, fmt.Errorf("CallGetRawSecretsV3: Unable to complete api request [err=%w]", err) } - if response.IsError() && strings.Contains(response.String(), "Failed to find bot key") { + if response.IsError() && strings.Contains(response.String(), "bot_not_found_error") { return GetRawSecretsV3Response{}, fmt.Errorf("project with id %s is a legacy project type, please navigate to project settings and disable end to end encryption then try again", request.WorkspaceId) } if response.IsError() { - return GetRawSecretsV3Response{}, fmt.Errorf("CallUniversalAuthLogin: Unsuccessful response [%v %v] [status-code=%v] [response=%v]", response.Request.Method, response.Request.URL, response.StatusCode(), response.String()) + return GetRawSecretsV3Response{}, fmt.Errorf("CallGetRawSecretsV3: Unsuccessful response [%v %v] [status-code=%v] [response=%v]", response.Request.Method, response.Request.URL, response.StatusCode(), response.String()) } return getRawSecretsV3Response, nil From f799e224a079cb384d5fc13d48f012ee22b2bdfc Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Wed, 13 Dec 2023 18:22:29 -0500 Subject: [PATCH 2/2] use RequestError instead of Error for bot --- backend/src/helpers/bot.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/helpers/bot.ts b/backend/src/helpers/bot.ts index 275ca0988..63814434d 100644 --- a/backend/src/helpers/bot.ts +++ b/backend/src/helpers/bot.ts @@ -13,7 +13,7 @@ import { SECRET_SHARED } from "../variables"; import { client, getEncryptionKey, getRootEncryptionKey } from "../config"; -import { InternalServerError } from "../utils/errors"; +import { BotNotFoundError, InternalServerError } from "../utils/errors"; import { Folder } from "../models"; import { getFolderByPath } from "../services/FolderService"; import { getAllImportedSecrets } from "../services/SecretImportService"; @@ -223,7 +223,7 @@ export const getKey = async ({ workspaceId }: { workspaceId: Types.ObjectId }) = workspace: workspaceId }).populate<{ sender: IUser }>("sender", "publicKey"); - if (!botKey) throw new Error("Failed to find bot key"); + if (!botKey) throw BotNotFoundError({ message: `getKey: Failed to find bot key for [workspaceId=${workspaceId}]` }) const bot = await Bot.findOne({ workspace: workspaceId