From 8dd230ea2faa4f4540a53d9650876f497ce8077f Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Thu, 9 Jul 2026 21:06:32 +0100 Subject: [PATCH] fix(GitHubPullRequestTransformer): remove fallback string (#1350) --- .../tests/GitHubPullRequestTransformer.test.ts | 6 +++--- .../GitHubPullRequestTransformer.ts | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/fluxer_api/src/api/webhook/tests/GitHubPullRequestTransformer.test.ts b/fluxer_api/src/api/webhook/tests/GitHubPullRequestTransformer.test.ts index 8f6bb79ae..5e28c46bc 100644 --- a/fluxer_api/src/api/webhook/tests/GitHubPullRequestTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/GitHubPullRequestTransformer.test.ts @@ -135,7 +135,7 @@ describe('GitHub Pull Request Transformer', () => { }; const result = await transformPullRequest(payload); expect(result).not.toBeNull(); - expect(result?.description).toBe(''); + expect(result?.description).toBeUndefined(); }); }); describe('transformPullRequestReview', () => { @@ -207,7 +207,7 @@ describe('GitHub Pull Request Transformer', () => { }; const result = await transformPullRequestReview(payload); expect(result).not.toBeNull(); - expect(result?.description).toBe('No description provided'); + expect(result?.description).toBeUndefined(); }); }); describe('transformPullRequestReviewComment', () => { @@ -279,7 +279,7 @@ describe('GitHub Pull Request Transformer', () => { }; const result = await transformPullRequestReviewComment(payload); expect(result).not.toBeNull(); - expect(result?.description).toBe('No description provided'); + expect(result?.description).toBeUndefined(); }); }); }); diff --git a/fluxer_api/src/api/webhook/transformers/GitHubPullRequestTransformer.ts b/fluxer_api/src/api/webhook/transformers/GitHubPullRequestTransformer.ts index cce3c62d9..0bafe4a3e 100644 --- a/fluxer_api/src/api/webhook/transformers/GitHubPullRequestTransformer.ts +++ b/fluxer_api/src/api/webhook/transformers/GitHubPullRequestTransformer.ts @@ -4,6 +4,12 @@ import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageR import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; import {parseString} from '../../utils/StringUtils'; +function parseDescription(value: string | null | undefined): string | undefined { + if (!value) return undefined; + const description = parseString(value, 350); + return description.length > 0 ? description : undefined; +} + export async function transformPullRequest(body: GitHubWebhook): Promise { if (!(body.pull_request && body.action && body.repository)) { return null; @@ -15,7 +21,7 @@ export async function transformPullRequest(body: GitHubWebhook): Promise