Skip to content

Commit fbc46cd

Browse files
committed
Show more semantic errors when trying to run prebuilds without a project
1 parent 8270af1 commit fbc46cd

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

components/dashboard/src/start/CreateWorkspace.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,15 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
207207
phase = StartPhase.Stopped;
208208
statusMessage = <UsageLimitReachedModal hints={this.state?.error?.data} />;
209209
break;
210+
case ErrorCodes.PROJECT_REQUIRED:
211+
statusMessage = (
212+
<p className="text-base text-gitpod-red w-96">
213+
<a className="gp-link" href="https://www.gitpod.io/docs/configure/projects">
214+
Learn more about projects
215+
</a>
216+
</p>
217+
);
218+
break;
210219
default:
211220
statusMessage = (
212221
<p className="text-base text-gitpod-red w-96">

components/gitpod-protocol/src/messaging/error.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export namespace ErrorCodes {
3535
// 430 Repository not whitelisted (custom status code)
3636
export const REPOSITORY_NOT_WHITELISTED = 430;
3737

38+
// 440 Prebuilds now always require a project (custom status code)
39+
export const PROJECT_REQUIRED = 440;
40+
3841
// 450 Payment error
3942
export const PAYMENT_ERROR = 450;
4043

components/server/ee/src/prebuilds/prebuild-manager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import { StopWorkspacePolicy } from "@gitpod/ws-manager/lib";
3535
import { error } from "console";
3636
import { IncrementalPrebuildsService } from "./incremental-prebuilds-service";
3737
import { PrebuildRateLimiterConfig } from "../../../src/workspace/prebuild-rate-limiter";
38+
import { ResponseError } from "vscode-ws-jsonrpc";
39+
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
3840

3941
export class WorkspaceRunningError extends Error {
4042
constructor(msg: string, public instance: WorkspaceInstance) {
@@ -124,10 +126,11 @@ export class PrebuildManager {
124126

125127
try {
126128
if (user.blocked) {
127-
throw new Error(`Blocked users cannot start prebuilds (${user.name})`);
129+
throw new ResponseError(ErrorCodes.USER_BLOCKED, `Blocked users cannot start prebuilds (${user.name})`);
128130
}
129131
if (!project) {
130-
throw new Error(
132+
throw new ResponseError(
133+
ErrorCodes.PROJECT_REQUIRED,
131134
`Running prebuilds without a project is no longer supported. Please add '${cloneURL}' as a project in a Gitpod team.`,
132135
);
133136
}

components/server/ee/src/prebuilds/start-prebuild-context-parser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66

77
import { User, WorkspaceContext, ContextURL } from "@gitpod/gitpod-protocol";
8+
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
89
import { injectable } from "inversify";
10+
import { ResponseError } from "vscode-ws-jsonrpc";
911
import { IPrefixContextParser } from "../../../src/workspace/context-parser";
1012

1113
@injectable()
@@ -19,7 +21,8 @@ export class StartPrebuildContextParser implements IPrefixContextParser {
1921
}
2022

2123
public async handle(user: User, prefix: string, context: WorkspaceContext): Promise<WorkspaceContext> {
22-
throw new Error(
24+
throw new ResponseError(
25+
ErrorCodes.PROJECT_REQUIRED,
2326
`Running prebuilds without a project is no longer supported. Please add your repository as a project in a Gitpod team.`,
2427
);
2528
}

0 commit comments

Comments
 (0)