Skip to content

Commit 1c4b9ff

Browse files
robstolarzclaude
andcommitted
fix: fall back to config org when --org not provided in sandbox commands
Without this, multi-org users who have set their org via `depot orgs set` still get Unauthorized errors from sandbox exec/pty/exec-pipe because the configured org is never read. Matches the pattern used by ci ssh and all other org-aware commands. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0a4e54c commit 1c4b9ff

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

pkg/cmd/sandbox/exec-pipe.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99

1010
"github.com/depot/cli/pkg/api"
11+
"github.com/depot/cli/pkg/config"
1112
"github.com/depot/cli/pkg/helpers"
1213
civ1 "github.com/depot/cli/pkg/proto/depot/ci/v1"
1314
"github.com/spf13/cobra"
@@ -40,6 +41,10 @@ func newSandboxExecPipe() *cobra.Command {
4041
orgID, err := cmd.Flags().GetString("org")
4142
cobra.CheckErr(err)
4243

44+
if orgID == "" {
45+
orgID = config.GetCurrentOrganization()
46+
}
47+
4348
sandboxID, err := cmd.Flags().GetString("sandbox-id")
4449
cobra.CheckErr(err)
4550

pkg/cmd/sandbox/exec.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"connectrpc.com/connect"
88
"github.com/depot/cli/pkg/api"
9+
"github.com/depot/cli/pkg/config"
910
"github.com/depot/cli/pkg/helpers"
1011
civ1 "github.com/depot/cli/pkg/proto/depot/ci/v1"
1112
"github.com/spf13/cobra"
@@ -41,6 +42,10 @@ func newSandboxExec() *cobra.Command {
4142
orgID, err := cmd.Flags().GetString("org")
4243
cobra.CheckErr(err)
4344

45+
if orgID == "" {
46+
orgID = config.GetCurrentOrganization()
47+
}
48+
4449
sandboxID, err := cmd.Flags().GetString("sandbox-id")
4550
cobra.CheckErr(err)
4651

pkg/cmd/sandbox/pty.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7+
"github.com/depot/cli/pkg/config"
78
"github.com/depot/cli/pkg/helpers"
89
"github.com/depot/cli/pkg/pty"
910
"github.com/spf13/cobra"
@@ -38,6 +39,10 @@ func newSandboxPty() *cobra.Command {
3839
orgID, err := cmd.Flags().GetString("org")
3940
cobra.CheckErr(err)
4041

42+
if orgID == "" {
43+
orgID = config.GetCurrentOrganization()
44+
}
45+
4146
sandboxID, err := cmd.Flags().GetString("sandbox-id")
4247
cobra.CheckErr(err)
4348

0 commit comments

Comments
 (0)