Skip to content

Commit 21a68d3

Browse files
committed
fix: handle empty org list gracefully during login
SelectOrganization() returns (nil, nil) when the org list is empty. Both `depot login` and `depot org switch` dereferenced the nil pointer, causing a panic. Now login completes successfully (token is saved) and prints a helpful message when no orgs are found. org switch returns a clear error. Made-with: Cursor
1 parent 4f2273d commit 21a68d3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pkg/cmd/login/login.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func NewCmdLogin() *cobra.Command {
4646
if err != nil {
4747
return err
4848
}
49+
if currentOrganization == nil {
50+
fmt.Println("Successfully authenticated!")
51+
fmt.Println("")
52+
fmt.Println("No organizations found. You can create one at https://depot.dev")
53+
return nil
54+
}
4955
orgId = currentOrganization.OrgId
5056
}
5157

pkg/cmd/org/switch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ func NewCmdSwitch() *cobra.Command {
2323
if err != nil {
2424
return err
2525
}
26+
if org == nil {
27+
return fmt.Errorf("no organizations found")
28+
}
2629
orgId = org.OrgId
2730
}
2831

0 commit comments

Comments
 (0)