Skip to content

Commit d1a4f6d

Browse files
chore: throw err if ws doesnt actually exist
1 parent 770c4ae commit d1a4f6d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

apps/workspace-engine/pkg/workspace/workspace.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"encoding/gob"
7+
"fmt"
78
"workspace-engine/pkg/changeset"
89
"workspace-engine/pkg/cmap"
910
"workspace-engine/pkg/db"
@@ -215,6 +216,16 @@ func HasWorkspace(id string) bool {
215216
}
216217

217218
func GetWorkspaceAndLoad(id string) (*Workspace, error) {
219+
ctx := context.Background()
220+
wsExistsInDB, err := db.WorkspaceExists(ctx, id)
221+
if err != nil {
222+
return nil, err
223+
}
224+
225+
if !wsExistsInDB {
226+
return nil, fmt.Errorf("workspace %s not found in database: %w", id, err)
227+
}
228+
218229
workspace, _ := workspaces.Get(id)
219230
if workspace == nil {
220231
workspace, err := NewAndLoad(context.Background(), id)

0 commit comments

Comments
 (0)