From df9a1646e6e02bedd4d9deb9dc1a7d8ea9c41602 Mon Sep 17 00:00:00 2001 From: Innei Date: Tue, 3 Sep 2024 19:14:19 +0800 Subject: [PATCH] fix: try debug fn error Signed-off-by: Innei --- .../src/modules/serverless/serverless.controller.ts | 11 +++++++---- apps/core/src/modules/snippet/snippet.service.ts | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/core/src/modules/serverless/serverless.controller.ts b/apps/core/src/modules/serverless/serverless.controller.ts index d88594bf46e..725223e9912 100644 --- a/apps/core/src/modules/serverless/serverless.controller.ts +++ b/apps/core/src/modules/serverless/serverless.controller.ts @@ -102,14 +102,17 @@ export class ServerlessController { getters: true, }) - const notExistMessage = 'serverless function is not exist or not enabled' - + const errorPath = `Path: /${reference}/${name}` if (!snippet) { - throw new NotFoundException(notExistMessage) + throw new NotFoundException( + `serverless function is not exist, ${errorPath}`, + ) } if (!snippet.enable) { - throw new NotFoundException(notExistMessage) + throw new BadRequestException( + `serverless function is not enabled, ${errorPath}`, + ) } if (snippet.private && !isAuthenticated) { diff --git a/apps/core/src/modules/snippet/snippet.service.ts b/apps/core/src/modules/snippet/snippet.service.ts index bea85d681ce..993ee7a5801 100644 --- a/apps/core/src/modules/snippet/snippet.service.ts +++ b/apps/core/src/modules/snippet/snippet.service.ts @@ -12,6 +12,7 @@ import { NotFoundException, } from '@nestjs/common' +import { RequestContext } from '~/common/contexts/request.context' import { EventScope } from '~/constants/business-event.constant' import { RedisKeys } from '~/constants/cache.constant' import { EventBusEvents } from '~/constants/event-bus.constant' @@ -263,7 +264,7 @@ export class SnippetService { throw new NotFoundException() } - if (snippet.private) { + if (snippet.private && !RequestContext.currentIsAuthenticated()) { throw new ForbiddenException('snippet is private') }