@@ -848,7 +848,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
848
848
const user = await this . checkUser ( "getTeamMembersByProject" ) ;
849
849
if ( projectId ) {
850
850
const project = await this . projectsService . getProject ( user . id , projectId ) ;
851
- if ( project && project . teamId ) {
851
+ if ( project . teamId ) {
852
852
return await this . organizationService . listMembers ( user . id , project . teamId ) ;
853
853
}
854
854
}
@@ -977,9 +977,23 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
977
977
throw new ApplicationError ( ErrorCodes . PERMISSION_DENIED , "Cannot (re-)start a deleted workspace." ) ;
978
978
}
979
979
const envVarsPromise = this . envVarService . resolve ( workspace ) ;
980
- const projectPromise = workspace . projectId
981
- ? this . projectsService . getProject ( user . id , workspace . projectId )
982
- : Promise . resolve ( undefined ) ;
980
+
981
+ const projectPromise = new Deferred < Project > ( ) ;
982
+ if ( workspace . projectId ) {
983
+ try {
984
+ const project = await this . projectsService . getProject ( user . id , workspace . projectId ) ;
985
+ projectPromise . resolve ( project ) ;
986
+ } catch ( error ) {
987
+ if ( ApplicationError . hasErrorCode ( error ) && error . code === ErrorCodes . NOT_FOUND ) {
988
+ log . info ( { userId : user . id , workspaceId } , "cannot resolve project" , error ) ;
989
+ projectPromise . resolve ( undefined ) ;
990
+ } else {
991
+ throw error ;
992
+ }
993
+ }
994
+ } else {
995
+ projectPromise . resolve ( undefined ) ;
996
+ }
983
997
984
998
await mayStartPromise ;
985
999
@@ -990,7 +1004,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
990
1004
ctx ,
991
1005
workspace ,
992
1006
user ,
993
- await projectPromise ,
1007
+ await projectPromise . promise ,
994
1008
await envVarsPromise ,
995
1009
options ,
996
1010
) ;
@@ -1593,9 +1607,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1593
1607
const user = await this . checkAndBlockUser ( "getPrebuildEvents" ) ;
1594
1608
1595
1609
const project = await this . projectsService . getProject ( user . id , projectId ) ;
1596
- if ( ! project ) {
1597
- throw new ApplicationError ( ErrorCodes . NOT_FOUND , "Project not found" ) ;
1598
- }
1599
1610
await this . guardProjectOperation ( user , projectId , "get" ) ;
1600
1611
1601
1612
const events = await this . projectsService . getPrebuildEvents ( user . id , project . cloneUrl ) ;
@@ -1612,9 +1623,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1612
1623
const user = await this . checkAndBlockUser ( "triggerPrebuild" ) ;
1613
1624
1614
1625
const project = await this . projectsService . getProject ( user . id , projectId ) ;
1615
- if ( ! project ) {
1616
- throw new ApplicationError ( ErrorCodes . NOT_FOUND , "Project not found" ) ;
1617
- }
1618
1626
await this . guardProjectOperation ( user , projectId , "update" ) ;
1619
1627
1620
1628
const branchDetails = ! ! branchName
@@ -2810,9 +2818,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2810
2818
2811
2819
private async guardProjectOperation ( user : User , projectId : string , op : ResourceAccessOp ) : Promise < void > {
2812
2820
const project = await this . projectsService . getProject ( user . id , projectId ) ;
2813
- if ( ! project ) {
2814
- throw new ApplicationError ( ErrorCodes . NOT_FOUND , "Project not found" ) ;
2815
- }
2816
2821
// Anyone who can read a team's information (i.e. any team member) can manage team projects
2817
2822
await this . guardTeamOperation ( project . teamId , "get" , "not_implemented" ) ;
2818
2823
}
@@ -2954,10 +2959,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2954
2959
2955
2960
const user = await this . checkAndBlockUser ( "cancelPrebuild" ) ;
2956
2961
2957
- const project = await this . projectsService . getProject ( user . id , projectId ) ;
2958
- if ( ! project ) {
2959
- throw new ApplicationError ( ErrorCodes . NOT_FOUND , "Project not found" ) ;
2960
- }
2962
+ await this . projectsService . getProject ( user . id , projectId ) ;
2961
2963
await this . guardProjectOperation ( user , projectId , "update" ) ;
2962
2964
2963
2965
const prebuild = await this . workspaceDb . trace ( ctx ) . findPrebuildByID ( prebuildId ) ;
0 commit comments