diff --git a/components/gitpod-protocol/src/gitpod-service.ts b/components/gitpod-protocol/src/gitpod-service.ts index 31f626816a5038..6470073eff891c 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -358,6 +358,8 @@ export interface ClientHeaderFields { clientRegion?: string; } +const WORKSPACE_MAXIMUM_TIMEOUT_HOURS = 24; + export type WorkspaceTimeoutDuration = string; export namespace WorkspaceTimeoutDuration { export function validate(duration: string): WorkspaceTimeoutDuration { @@ -369,6 +371,12 @@ export namespace WorkspaceTimeoutDuration { if (isNaN(value) || value <= 0) { throw new Error(`Invalid timeout value: ${duration}`); } + if ( + (unit === "h" && value > WORKSPACE_MAXIMUM_TIMEOUT_HOURS) || + (unit === "m" && value > WORKSPACE_MAXIMUM_TIMEOUT_HOURS * 60) + ) { + throw new Error(`Timeouts cannot extend to more than a day`); + } return duration; } }