From afa71c4b2fa7c99f0267a35046e8419c8a72db06 Mon Sep 17 00:00:00 2001 From: Charlie Andrews Date: Tue, 15 Mar 2022 12:21:46 -0400 Subject: [PATCH] Disallow ssh'ing to codespace with a pending operation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the API already disallows this, this makes the error cleaner and more explicit when a user is trying to start/ssh into a codespace that has a pending operation. Example of the old error message: ``` $ gh cs ssh -c cwndrws-redacted Starting codespace ⣽error connecting to codespace: error starting codespace: HTTP 422: your codespace has an operation pending: updating to a sku with a different amount of storage; please wait until this operation is complete (https://api.github.com/user/codespaces/cwndrws-redacted/start) exit status 1 ``` Example of the new error message: ``` $ gh cs ssh -c cwndrws-redacted codespace is disabled while it has a pending operation: Changing machine types... exit status 1 ``` --- pkg/cmd/codespace/ssh.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/cmd/codespace/ssh.go b/pkg/cmd/codespace/ssh.go index 6ce783f2f..af6c86614 100644 --- a/pkg/cmd/codespace/ssh.go +++ b/pkg/cmd/codespace/ssh.go @@ -128,6 +128,13 @@ func (a *App) SSH(ctx context.Context, sshArgs []string, opts sshOptions) (err e return fmt.Errorf("get or choose codespace: %w", err) } + if codespace.PendingOperation { + return fmt.Errorf( + "codespace is disabled while it has a pending operation: %s", + codespace.PendingOperationDisabledReason, + ) + } + liveshareLogger := noopLogger() if opts.debug { debugLogger, err := newFileLogger(opts.debugFile)