From 83a9527b507542efd7e909e0957e02070076f792 Mon Sep 17 00:00:00 2001 From: tipusinghaw Date: Wed, 23 Aug 2023 16:22:37 +0530 Subject: [PATCH 1/2] fix: added validation for agent url Signed-off-by: tipusinghaw --- apps/agent-service/src/agent-service.service.ts | 4 ++++ libs/common/src/response-messages/index.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/agent-service/src/agent-service.service.ts b/apps/agent-service/src/agent-service.service.ts index 1fb00b4d6..b76fd1faf 100644 --- a/apps/agent-service/src/agent-service.service.ts +++ b/apps/agent-service/src/agent-service.service.ts @@ -846,6 +846,9 @@ export class AgentServiceService { async getAgentHealthDetails(orgId: number): Promise { try { const orgAgentDetails: org_agents = await this.agentServiceRepository.getOrgAgentDetails(orgId); + if (!orgAgentDetails) { + throw new NotFoundException(ResponseMessages.agent.error.agentNotExists); + } if (orgAgentDetails.agentEndPoint) { const data = await this.commonService .httpGet(`${orgAgentDetails.agentEndPoint}/agent`, { headers: { 'x-api-key': '' } }) @@ -857,6 +860,7 @@ export class AgentServiceService { } catch (error) { this.logger.error(`Agent health details : ${JSON.stringify(error)}`); + throw new RpcException(error); } } } diff --git a/libs/common/src/response-messages/index.ts b/libs/common/src/response-messages/index.ts index 166416fdb..7cd59c48f 100644 --- a/libs/common/src/response-messages/index.ts +++ b/libs/common/src/response-messages/index.ts @@ -123,7 +123,8 @@ export const ResponseMessages = { apiEndpointNotFound: 'apiEndpoint not found', notAbleToSpinUpAgent: 'Agent not able to spin-up', alreadySpinUp: 'Agent already spin-up', - agentUrl: 'Agent url not exist' + agentUrl: 'Agent url not exist', + agentNotExists: 'Agent not spinned up for this organization' } }, connection: { From 3dc046c83846790852c17d6987a66f86fcd99177 Mon Sep 17 00:00:00 2001 From: tipusinghaw Date: Wed, 23 Aug 2023 17:02:45 +0530 Subject: [PATCH 2/2] fix: get schema by org id Signed-off-by: tipusinghaw --- apps/ledger/src/schema/repositories/schema.repository.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/ledger/src/schema/repositories/schema.repository.ts b/apps/ledger/src/schema/repositories/schema.repository.ts index abb7eb4a3..235c0aa62 100644 --- a/apps/ledger/src/schema/repositories/schema.repository.ts +++ b/apps/ledger/src/schema/repositories/schema.repository.ts @@ -112,7 +112,9 @@ export class SchemaRepository { }); const schemasCount = await this.prisma.schema.count({ where: { - orgId + organisation: { + id: orgId + } } }); return {schemasCount, schemasResult};