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

tsh db ls panics with index out of range error #13130

Closed
Erick-Reyes opened this issue Jun 2, 2022 · 7 comments · Fixed by #17777
Closed

tsh db ls panics with index out of range error #13130

Erick-Reyes opened this issue Jun 2, 2022 · 7 comments · Fixed by #17777
Assignees
Labels
bug c-cs Internal Customer Reference c-tho Internal Customer Reference database-access Database access related issues and PRs tsh tsh - Teleport's command line tool for logging into nodes running Teleport. windows

Comments

@Erick-Reyes
Copy link
Contributor

Erick-Reyes commented Jun 2, 2022

Expected behavior:
When installing tsh on windows, it should output tsh db ls without any issues.

Current behavior:
When installing tsh on windows tsh db ls outputs consistent errors. This is after successfully login to desired db as so:
tsh db login --db-user={USER} --db-name={DBNAME} {DATABASE}
Originally, issue was first notice on AWS workspace and then they could replicate it on Windows 10 laptop.
Note: They have not encountered the same problem on a MacOS install

Bug details:

  • Teleport version:
    Teleport Enterprise v9.0.0 git:v9.0.0-0-g1fa8857aa go1.17.7
    PS D:\> tsh version Teleport v9.2.4 git:v9.2.4-0-g86d887eff go1.17.10

  • Recreation steps:

  1. tsh login --proxy=example.proxy.com:443 --auth=okta [email protected]
  2. tsh db ls <== works as expected
  3. tsh db login exampledb
  4. tsh db ls <== now consistently outputs the error above
  • Debug logs:
PS D:\Users\dbuser\teleport-v9.1.3-windows-amd64-bin\teleport> tsh db ls
panic: runtime error: slice bounds out of range [:-4]

goroutine 1 [running]:
github.com/gravitational/teleport/lib/asciitable.(*Table).truncateCell(0xc0011864b0, 0x2, {0xc000f68090, 0x8})
        /go/src/github.com/gravitational/teleport/lib/asciitable/table.go:149 +0x190
github.com/gravitational/teleport/lib/asciitable.(*Table).AddRow(0xc0011864b0, {0xc0001613b0, 0x5, 0x5})
        /go/src/github.com/gravitational/teleport/lib/asciitable/table.go:131 +0xa6
github.com/gravitational/teleport/lib/asciitable.MakeTableWithTruncatedColumn({0xc001186830, 0x5, 0xc000091600}, {0xc000
9b5800, 0x42, 0x0}, {0x238811d, 0x6})
        /go/src/github.com/gravitational/teleport/lib/asciitable/table.go:116 +0x2d0
main.showDatabasesAsText({0x0, 0x0}, {0xc000b92800, 0x42, 0xc000e3eab0}, {0xc000157440, 0x1, 0x0}, {0xc000091600, 0x7, .
..}, ...)
        /go/src/github.com/gravitational/teleport/tool/tsh/tsh.go:1779 +0x97e
main.showDatabases({0x0, 0x0}, {0xc000b92800, 0x42, 0x80}, {0xc000157440, 0x1, 0x1}, {0xc000091600, 0x7, ...}, ...)
        /go/src/github.com/gravitational/teleport/tool/tsh/tsh.go:1707 +0x11f
main.onListDatabases(0xc0001e2480)
        /go/src/github.com/gravitational/teleport/tool/tsh/db.go:90 +0x5db
main.Run({0xc000156010, 0x2, 0x3}, {0x0, 0x0, 0xc000072000})
        /go/src/github.com/gravitational/teleport/tool/tsh/tsh.go:783 +0xfc77
main.main()
        /go/src/github.com/gravitational/teleport/tool/tsh/tsh.go:349 +0x218```

gz#6793
@Erick-Reyes Erick-Reyes added bug windows c-tho Internal Customer Reference labels Jun 2, 2022
@zmb3
Copy link
Collaborator

zmb3 commented Jun 2, 2022

Looks like this is the offending line (MaxCellLength can end up negative if width and totalLen are equal):

column.MaxCellLength = width - totalLen - len("... ")

@lxea can you have a look?

@zmb3 zmb3 added the tsh tsh - Teleport's command line tool for logging into nodes running Teleport. label Jun 2, 2022
@zmb3 zmb3 changed the title Windows tsh installation tsh db ls panics with index out of range error Jun 7, 2022
@oshati oshati added c-cs Internal Customer Reference database-access Database access related issues and PRs labels Sep 12, 2022
@jwieder
Copy link
Contributor

jwieder commented Oct 17, 2022

If anyone reaches this issue before it is resolved, you can generally extend the width of your console window and re-run tsh db ls as a quick workaround.

@strideynet
Copy link
Contributor

This issue also reproduces when using tsh within CircleCI.

@tutuca
Copy link

tutuca commented Dec 18, 2024

This is still happening on macos sequoia with iterm2 on a maximized window.

@zmb3
Copy link
Collaborator

zmb3 commented Dec 19, 2024

happening on macos sequoia

What version of tsh?

@tutuca
Copy link

tutuca commented Dec 19, 2024

I'm on 10.1.9, client and server.

@zmb3
Copy link
Collaborator

zmb3 commented Dec 19, 2024

That's super old and end of life. Happy to reopen the issue if you reproduce on a newer version (v15+), otherwise we will assume it's been fixed since then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c-cs Internal Customer Reference c-tho Internal Customer Reference database-access Database access related issues and PRs tsh tsh - Teleport's command line tool for logging into nodes running Teleport. windows
Projects
None yet
7 participants