Skip to content

Commit 63129b0

Browse files
committed
Handle appeal content that's all whitespace PM-1983
1 parent fbb55ee commit 63129b0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/api/appeal/appeal.controller.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ export class AppealController {
7777
this.logger.log(`Creating appeal`);
7878
const authUser = req['user'] as JwtUser;
7979
try {
80+
const trimmedContent = body.content?.trim();
81+
if (!trimmedContent) {
82+
throw new BadRequestException({
83+
message: 'Appeal content must not be empty.',
84+
code: 'EMPTY_APPEAL_CONTENT',
85+
});
86+
}
87+
8088
// Get challengeId by following the relationship chain
8189
const reviewItemComment =
8290
await this.prisma.reviewItemComment.findUniqueOrThrow({
@@ -116,7 +124,7 @@ export class AppealController {
116124
await this.challengeApiService.validateAppealSubmission(challengeId);
117125

118126
const data = await this.prisma.appeal.create({
119-
data: { ...body },
127+
data: { ...body, content: trimmedContent },
120128
});
121129
this.logger.log(`Appeal created with ID: ${data.id}`);
122130
return data as AppealResponseDto;

0 commit comments

Comments
 (0)