Description
- Node.js version: 22
- Gitbeaker version: @gitbeaker/rest: ^38.0.0 (used via danger-js)
- Gitbeaker release (cli, rest, core, requester-utils): rest, core
- OS & version: macOS Sonoma
The CondensedMergeRequestSchema interface defines description as a required string. However, the GitLab API returns null for this field when a Merge Request is created without a description (a common occurrence when using IDE integrations like IntelliJ). This causes a crash or type error when the library attempts to handle the null value.
Steps to reproduce
- Create a Merge Request in GitLab (e.g., via IntelliJ) without entering any text in the description field.
- Run a script using
@gitbeaker/rest (or danger-js) that fetches this specific Merge Request.
- The process will fail when it tries to map the API response to the
CondensedMergeRequestSchema.
Expected behaviour
The description field should be nullable (string | null) to safely accommodate Merge Requests that do not have a description.
Actual behaviour
The application crashes or throws an error because it receives null for a field typed strictly as a string.
Possible fixes
In packages/core/src/resources/MergeRequests.ts, update the CondensedMergeRequestSchema interface as follows:
interface CondensedMergeRequestSchema extends Record<string, unknown> {
id: number;
iid: number;
project_id: number;
title: string;
description: string | null; // Allow null to prevent crashes
state: string;
created_at: string;
updated_at: string;
web_url: string;
}
Checklist
Description
The
CondensedMergeRequestSchemainterface definesdescriptionas a requiredstring. However, the GitLab API returnsnullfor this field when a Merge Request is created without a description (a common occurrence when using IDE integrations like IntelliJ). This causes a crash or type error when the library attempts to handle the null value.Steps to reproduce
@gitbeaker/rest(ordanger-js) that fetches this specific Merge Request.CondensedMergeRequestSchema.Expected behaviour
The
descriptionfield should be nullable (string | null) to safely accommodate Merge Requests that do not have a description.Actual behaviour
The application crashes or throws an error because it receives
nullfor a field typed strictly as astring.Possible fixes
In
packages/core/src/resources/MergeRequests.ts, update theCondensedMergeRequestSchemainterface as follows:Checklist