Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-prompt crashes on Windows outside of WSL #475

Open
DainiusSal opened this issue Apr 17, 2023 · 4 comments
Open

go-prompt crashes on Windows outside of WSL #475

DainiusSal opened this issue Apr 17, 2023 · 4 comments
Labels
bug Something isn't working windows

Comments

@DainiusSal
Copy link

Output of aws-sso version:

Example output:
AWS SSO CLI Version 1.9.10 -- Copyright 2021-2022 Aaron Turner
11ec65288f78702a5e80078c04e0ef8b4ac7cb67 (v1.9.10) built at 2023-03-03T22:12:08+0000

Describe the bug:
When the cached AWS credentials for a chained role are outdated, aws-sso exec throws an error instead of updating the cached values.

To Reproduce:

  1. Define a AWS chained role in config.yaml
  2. Assume the role
  3. Wait for credentials to become invalid
  4. Assume the role again

Expected behavior:
Cache is updated automatically and I am able to assume the role without errors.

Desktop:

  • OS: Windows
  • Version 11

Additional context:
If I delete cache.json- I can assume the role again until the credentials become invalid.

Error output from aws-sso exec when assuming the role with outdated credentials:

panic: assignment to entry in nil map
        panic: close of closed channel

goroutine 1 [running]:
github.com/mattn/go-tty.(*TTY).close(0xc000482a50)
        /home/runner/go/pkg/mod/github.com/mattn/go-tty@v0.0.3/tty_windows.go:331 +0x90
github.com/mattn/go-tty.(*TTY).Close(...)
        /home/runner/go/pkg/mod/github.com/mattn/go-tty@v0.0.3/tty.go:38
github.com/c-bata/go-prompt.(*WindowsParser).TearDown(0x38?)
        /home/runner/go/pkg/mod/github.com/c-bata/go-prompt@v0.2.5/input_windows.go:37 +0x1c
github.com/c-bata/go-prompt.(*Prompt).tearDown(0xc00011d170)
        /home/runner/go/pkg/mod/github.com/c-bata/go-prompt@v0.2.5/prompt.go:293 +0x32
panic({0xf219a0, 0x10b2c80})
        /opt/hostedtoolcache/go/1.18.10/x64/src/runtime/panic.go:838 +0x207
github.com/synfinatic/aws-sso-cli/sso.(*Cache).AddHistory(0xc000410d80, {0xc000018cc0, 0x24})
        /home/runner/work/aws-sso-cli/aws-sso-cli/sso/cache.go:168 +0x1079
main.execCmd(0xc00002d8f0, 0x24?, 0x0?, {0xc0001d0770, 0x5})
        /home/runner/work/aws-sso-cli/aws-sso-cli/cmd/aws-sso/exec_cmd.go:117 +0xc7
main.(*TagsCompleter).Executor(0xc000411400, {0xc0000c0980?, 0xc000482a50?})
        /home/runner/work/aws-sso-cli/aws-sso-cli/cmd/aws-sso/select.go:109 +0x2c3
github.com/c-bata/go-prompt.(*Prompt).Run(0xc00011d170)
        /home/runner/go/pkg/mod/github.com/c-bata/go-prompt@v0.2.5/prompt.go:84 +0x745
main.(*ExecCmd).Run(0x1?, 0xc00002d8f0)
        /home/runner/work/aws-sso-cli/aws-sso-cli/cmd/aws-sso/exec_cmd.go:109 +0x425
reflect.Value.call({0xf10de0?, 0xc000121948?, 0x18?}, {0xfb61fb, 0x4}, {0xc000004f90, 0x1, 0x0?})
        /opt/hostedtoolcache/go/1.18.10/x64/src/reflect/value.go:556 +0x845
reflect.Value.Call({0xf10de0?, 0xc000121948?, 0xf2aee0?}, {0xc000004f90, 0x1, 0x1})
        /opt/hostedtoolcache/go/1.18.10/x64/src/reflect/value.go:339 +0xbf
github.com/alecthomas/kong.callMethod({0xfb5d41, 0x3}, {0xf87dc0?, 0xc000121948?, 0x3?}, {0xf10de0?, 0xc000121948?, 0x0?}, 0xffde50?)
        /home/runner/go/pkg/mod/github.com/alecthomas/kong@v0.7.1/callbacks.go:95 +0x4e7
github.com/alecthomas/kong.(*Context).RunNode(0xc000236580, 0xc0001c44b0, {0xc0000cbec0, 0x1, 0x1})
        /home/runner/go/pkg/mod/github.com/alecthomas/kong@v0.7.1/context.go:755 +0x5f7
github.com/alecthomas/kong.(*Context).Run(0xc0001c52c0?, {0xc0000cbec0?, 0xfb98a5?, 0x0?})
        /home/runner/go/pkg/mod/github.com/alecthomas/kong@v0.7.1/context.go:780 +0x14e
main.main()
        /home/runner/work/aws-sso-cli/aws-sso-cli/cmd/aws-sso/main.go:200 +0x9ea

Contents of ~/.aws-sso/config.yaml:

SSOConfig:
    DefaultSSO:
        SSORegion: us-east-1
        StartUrl: https://*******.awsapps.com/start
        Accounts:
            "************":
                Name: AccountName
                Roles:
                    role-to-assume:
                        Via: arn:aws:iam::************:role/IntermediateRole
                DefaultRegion: us-east-1
        DefaultRegion: us-east-1
DefaultSSO: DefaultSSO
DefaultRegion: us-east-1
ConsoleDuration: 60
CacheRefresh: 168
Threads: 5
AutoConfigCheck: true
UrlAction: open
ConfigProfilesUrlAction: open
LogLevel: error
HistoryLimit: 10
HistoryMinutes: 1440
ProfileFormat: "{{ .AccountId }}:{{ .RoleName }}"
AccountPrimaryTag:
    - AccountName
    - AccountAlias
    - Email
PromptColors:
    descriptionbgcolor: Turquoise
    descriptiontextcolor: Black
    inputbgcolor: DefaultColor
    inputtextcolor: DefaultColor
    prefixbackgroundcolor: DefaultColor
    prefixtextcolor: Blue
    previewsuggestionbgcolor: DefaultColor
    previewsuggestiontextcolor: Green
    scrollbarbgcolor: Cyan
    scrollbarthumbcolor: LightGrey
    selecteddescriptionbgcolor: DarkGray
    selecteddescriptiontextcolor: White
    selectedsuggestionbgcolor: DarkGray
    selectedsuggestiontextcolor: White
    suggestionbgcolor: Cyan
    suggestiontextcolor: White
ListFields:
    - AccountId
    - AccountAlias
    - RoleName
    - Profile
    - ExpiresStr
    - Arn
@DainiusSal DainiusSal added the bug Something isn't working label Apr 17, 2023
@synfinatic
Copy link
Owner

FYI, was not able to reproduce this on macOS. The fact I'm seeing go-prompt in the backtrace makes me think this is Windows related. Are you running aws-sso under WSL? If not, care trying that?

@synfinatic
Copy link
Owner

@DainiusSal did you get a chance to try this under WSL?

@DainiusSal
Copy link
Author

Hi, @synfinatic. Sorry for the late reply. I tried it out on WSL and it did work as expected. Seems like it is a Windows related issue.

@synfinatic
Copy link
Owner

synfinatic commented May 9, 2023

Thanks for confirming! FWIW, aws-sso support in windows is still a bit experimental at this point. Need to find a better Go library for dealing with interactive prompts that doesn't crash with Windows terminal limitations.

@synfinatic synfinatic changed the title Cannot assume chained roles after cached credentials are invalidated go-prompt crashes on Windows outside of WSL Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows
Projects
None yet
Development

No branches or pull requests

2 participants