Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@ APACHE 2.0 LICENSED DEPENDENCIES

- github.com/aws/aws-sdk-go-v2/config
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/config/v1.31.18/config/LICENSE.txt
URL: https://github.com/aws/aws-sdk-go-v2/blob/config/v1.31.20/config/LICENSE.txt

- github.com/aws/aws-sdk-go-v2/credentials
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/credentials/v1.18.22/credentials/LICENSE.txt
URL: https://github.com/aws/aws-sdk-go-v2/blob/credentials/v1.18.24/credentials/LICENSE.txt

- github.com/aws/aws-sdk-go-v2/feature/ec2/imds
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/feature/ec2/imds/v1.18.13/feature/ec2/imds/LICENSE.txt

- github.com/aws/aws-sdk-go-v2/feature/s3/manager
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/feature/s3/manager/v1.20.5/feature/s3/manager/LICENSE.txt
URL: https://github.com/aws/aws-sdk-go-v2/blob/feature/s3/manager/v1.20.7/feature/s3/manager/LICENSE.txt

- github.com/aws/aws-sdk-go-v2/internal/configsources
License: Apache-2.0
Expand Down Expand Up @@ -155,27 +155,27 @@ APACHE 2.0 LICENSED DEPENDENCIES

- github.com/aws/aws-sdk-go-v2/service/s3
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/s3/v1.90.0/service/s3/LICENSE.txt
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/s3/v1.90.2/service/s3/LICENSE.txt

- github.com/aws/aws-sdk-go-v2/service/secretsmanager
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/secretsmanager/v1.35.4/service/secretsmanager/LICENSE.txt

- github.com/aws/aws-sdk-go-v2/service/ssm
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/ssm/v1.67.0/service/ssm/LICENSE.txt
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/ssm/v1.67.2/service/ssm/LICENSE.txt

- github.com/aws/aws-sdk-go-v2/service/sso
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/sso/v1.30.1/service/sso/LICENSE.txt
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/sso/v1.30.3/service/sso/LICENSE.txt

- github.com/aws/aws-sdk-go-v2/service/ssooidc
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/ssooidc/v1.35.5/service/ssooidc/LICENSE.txt
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/ssooidc/v1.35.7/service/ssooidc/LICENSE.txt

- github.com/aws/aws-sdk-go-v2/service/sts
License: Apache-2.0
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/sts/v1.40.0/service/sts/LICENSE.txt
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/sts/v1.40.2/service/sts/LICENSE.txt

- github.com/aws/smithy-go
License: Apache-2.0
Expand Down Expand Up @@ -299,7 +299,7 @@ APACHE 2.0 LICENSED DEPENDENCIES

- github.com/googleapis/enterprise-certificate-proxy/client
License: Apache-2.0
URL: https://github.com/googleapis/enterprise-certificate-proxy/blob/v0.3.6/LICENSE
URL: https://github.com/googleapis/enterprise-certificate-proxy/blob/v0.3.7/LICENSE

- github.com/gosimple/unidecode
License: Apache-2.0
Expand Down Expand Up @@ -495,7 +495,7 @@ APACHE 2.0 LICENSED DEPENDENCIES

- google.golang.org/genproto/googleapis/rpc
License: Apache-2.0
URL: https://github.com/googleapis/go-genproto/blob/ab9386a59fda/googleapis/rpc/LICENSE
URL: https://github.com/googleapis/go-genproto/blob/f26f9409b101/googleapis/rpc/LICENSE

- google.golang.org/grpc
License: Apache-2.0
Expand Down Expand Up @@ -740,7 +740,7 @@ BSD LICENSED DEPENDENCIES

- golang.org/x/mod/semver
License: BSD-3-Clause
URL: https://cs.opensource.google/go/x/mod/+/v0.28.0:LICENSE
URL: https://cs.opensource.google/go/x/mod/+/v0.29.0:LICENSE

- golang.org/x/net
License: BSD-3-Clause
Expand All @@ -752,19 +752,19 @@ BSD LICENSED DEPENDENCIES

- golang.org/x/sync
License: BSD-3-Clause
URL: https://cs.opensource.google/go/x/sync/+/v0.17.0:LICENSE
URL: https://cs.opensource.google/go/x/sync/+/v0.18.0:LICENSE

- golang.org/x/sys
License: BSD-3-Clause
URL: https://cs.opensource.google/go/x/sys/+/v0.37.0:LICENSE
URL: https://cs.opensource.google/go/x/sys/+/v0.38.0:LICENSE

- golang.org/x/term
License: BSD-3-Clause
URL: https://cs.opensource.google/go/x/term/+/v0.36.0:LICENSE
URL: https://cs.opensource.google/go/x/term/+/v0.37.0:LICENSE

- golang.org/x/text
License: BSD-3-Clause
URL: https://cs.opensource.google/go/x/text/+/v0.30.0:LICENSE
URL: https://cs.opensource.google/go/x/text/+/v0.31.0:LICENSE

- golang.org/x/time/rate
License: BSD-3-Clause
Expand All @@ -776,11 +776,11 @@ BSD LICENSED DEPENDENCIES

- google.golang.org/api
License: BSD-3-Clause
URL: https://github.com/googleapis/google-api-go-client/blob/v0.255.0/LICENSE
URL: https://github.com/googleapis/google-api-go-client/blob/v0.256.0/LICENSE

- google.golang.org/api/internal/third_party/uritemplates
License: BSD-3-Clause
URL: https://github.com/googleapis/google-api-go-client/blob/v0.255.0/internal/third_party/uritemplates/LICENSE
URL: https://github.com/googleapis/google-api-go-client/blob/v0.256.0/internal/third_party/uritemplates/LICENSE

- google.golang.org/protobuf
License: BSD-3-Clause
Expand Down Expand Up @@ -1206,7 +1206,7 @@ MIT LICENSED DEPENDENCIES

- github.com/getsentry/sentry-go
License: MIT
URL: https://github.com/getsentry/sentry-go/blob/v0.27.0/LICENSE
URL: https://github.com/getsentry/sentry-go/blob/v0.36.2/LICENSE

- github.com/go-logfmt/logfmt
License: MIT
Expand Down
8 changes: 8 additions & 0 deletions cmd/terraform_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ func handleInteractiveIdentitySelection(info *schema.ConfigAndStacksInfo) {
// GetDefaultIdentity() handles TTY and CI detection via isInteractive().
selectedIdentity, err := authManager.GetDefaultIdentity(true)
if err != nil {
// Check if user explicitly aborted (Ctrl+C, ESC, etc.).
// In this case, we want to exit immediately without showing an error.
if errors.Is(err, errUtils.ErrUserAborted) {
log.Debug("User aborted identity selection, exiting with SIGINT code")
// Exit immediately with POSIX SIGINT exit code.
// Note: We bypass error formatting as user abort is not an error condition.
errUtils.Exit(errUtils.ExitCodeSIGINT)
}
errUtils.CheckErrorPrintAndExit(fmt.Errorf("%w: %w", errUtils.ErrDefaultIdentity, err), "", "")
}

Expand Down
38 changes: 38 additions & 0 deletions cmd/terraform_utils_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"testing"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -218,3 +219,40 @@ func TestTerraformIdentityFlagHandling(t *testing.T) {
})
}
}

// TestUserAbortExitCode tests that ErrUserAborted results in exit code 130.
// This is a regression test for the bug where pressing Ctrl+C during identity
// selection would not properly exit the program, causing terraform to continue executing.
//
// The fix ensures that when GetDefaultIdentity returns ErrUserAborted, we immediately
// exit with code 130 (POSIX SIGINT: 128 + 2) before falling through to the generic
// error handler.
func TestUserAbortExitCode(t *testing.T) {
// Save original OsExit and restore it after the test.
originalOsExit := errUtils.OsExit
defer func() {
errUtils.OsExit = originalOsExit
}()

// Track whether Exit was called and with what code.
var exitCalled bool
var exitCode int
errUtils.OsExit = func(code int) {
exitCalled = true
exitCode = code
// Don't actually exit during the test.
}

// Simulate the error handling logic from handleInteractiveIdentitySelection.
// This is the key fix: when we get ErrUserAborted, we should exit with code 130.
err := errUtils.ErrUserAborted

// This is the fix applied in terraform_utils.go:handleInteractiveIdentitySelection
if errors.Is(err, errUtils.ErrUserAborted) {
errUtils.Exit(errUtils.ExitCodeSIGINT)
}

// Verify that Exit was called with the correct exit code.
assert.True(t, exitCalled, "Exit should have been called when user aborts")
assert.Equal(t, errUtils.ExitCodeSIGINT, exitCode, "Exit code should be ExitCodeSIGINT (POSIX SIGINT: 128 + 2)")
}
Loading