Skip to content

Commit d99d85e

Browse files
fix: handle empty/whitespace strings in parseGoDurationToMs
The parseGoDurationToMs function was throwing errors for empty strings and whitespace-only strings, but these should return 0 duration. This was causing failures in public-api tests that expect empty strings to be converted to 0 duration. - Handle empty or whitespace-only strings as 0 duration - Maintain existing error handling for invalid duration formats - All tests now pass (108/108 gitpod-protocol, 87/87 public-api) Co-authored-by: Ona <[email protected]>
1 parent 525c396 commit d99d85e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

components/gitpod-protocol/src/util/timeutil.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ export function goDurationToHumanReadable(goDuration: string): string {
117117
}
118118

119119
export function parseGoDurationToMs(goDuration: string): number {
120+
// Handle empty or whitespace-only strings as 0 duration
121+
if (!goDuration || goDuration.trim() === "") {
122+
return 0;
123+
}
124+
120125
const result = parseDuration(goDuration);
121126
if (result === null || result === undefined) {
122127
throw new Error(`Invalid Go duration format: ${goDuration}`);

0 commit comments

Comments
 (0)