community
community copied to clipboard
Handle CLI token expiration more gracefully
Description
If a user is working in the CLI and their token expires, the error message is not very helpful:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x155d743]
Strangely, things are handled much better when the token has been expired for a very long time.
Value
It's not very intuitive as to what may have gone wrong, and the user is more likely to assume there is a Vela bug rather than their login expired.
Definition of Done
Running a Vela CLI command after a login session has expired returns an error similar to what is shown when the user hasn't logged in for a long time:
DEBU[0000] access token has expired
FATA[0000] your tokens have expired - please log in again with 'vela login'
i am not able to replicate this. do you know if this is still an issue? what version of the CLI?
i am not able to replicate this. do you know if this is still an issue? what version of the CLI?
vela --version
vela version v0.14.1
Steps for replication (for me, at least — maybe this is a terminal emulator issue?):
-
vela login --api.addr <wherever>
-
vela view repo --org <OrgName> --repo <RepoName>
-> should show repo contents - set a timer for 15 minutes
- At the conclusion of the timer, run the same command in Step 2
- Error should look like this:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1563ba3] ........
i know i've seen this, but i can't replicate following the steps you outlined @ecrupper.
with trace logging, i see it goes from (access token expires):
DEBU[0000] access token has expired
DEBU[0000] fetching new access token with existing refresh token
to (refresh token expires):
DEBU[0000] access token has expired
FATA[0000] your tokens have expired - please log in again with 'vela login'
as expected. i also ran the vela view ..
command every second to make sure i didn't miss a weird time window.
if you run into this again, can you share the whole stacktrace?
example stacktraces
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x15af98e]
goroutine 1 [running]:
github.com/go-vela/sdk-go/vela.(*Client).addAuthentication(0xc00021fb80, 0xc000110900)
/home/runner/go/pkg/mod/github.com/go-vela/[email protected]/vela/client.go:215 +0x12e
github.com/go-vela/sdk-go/vela.(*Client).NewRequest(0xc00021fb80, {0x2c664ba, 0x4}, {0xc00027a330?, 0x10102c5?}, {0x2bdc780, 0xc00011b260})
/home/runner/go/pkg/mod/github.com/go-vela/[email protected]/vela/client.go:319 +0x24d
github.com/go-vela/sdk-go/vela.(*Client).Call(0x2c8da9f?, {0x2c664ba?, 0xc0006074c8?}, {0xc00027a330?, 0x2?}, {0x2bdc780?, 0xc00011b260?}, {0x2bdc780, 0xc00011b2c0})
/home/runner/go/pkg/mod/github.com/go-vela/[email protected]/vela/client.go:415 +0x3f
github.com/go-vela/sdk-go/vela.(*DeploymentService).Add(0xc00078ac78, {0x7ff7bfefebc2?, 0x2c9b7ca?}, {0x7ff7bfefebd4, 0x6}, 0xb0?)
/home/runner/go/pkg/mod/github.com/go-vela/[email protected]/vela/deployment.go:58 +0x105
github.com/go-vela/cli/action/deployment.(*Config).Add(0xc0000f1130, 0xc00021fb80)
/home/runner/work/cli/cli/action/deployment/add.go:65 +0x245
github.com/go-vela/cli/command/deployment.add(0x4023500?)
/home/runner/work/cli/cli/command/deployment/add.go:151 +0x34e
github.com/urfave/cli/v2.(*Command).Run(0x4023500, 0xc000215500, {0xc0000f1080, 0xb, 0xb})
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:274 +0x998
github.com/urfave/cli/v2.(*Command).Run(0x4022060, 0xc000215380, {0xc000000d80, 0xc, 0xc})
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:267 +0xbe5
github.com/urfave/cli/v2.(*Command).Run(0xc000793340, 0xc000214b40, {0xc000050820, 0xd, 0xd})
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:267 +0xbe5
github.com/urfave/cli/v2.(*App).RunContext(0xc0005b01e0, {0x2f82ef8?, 0x40722c0}, {0xc000050820, 0xd, 0xd})
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:332 +0x5b7
github.com/urfave/cli/v2.(*App).Run(...)
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:309
main.main()
/home/runner/work/cli/cli/cmd/vela-cli/main.go:137 +0x10df
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1589f6e]
goroutine 1 [running]:
github.com/go-vela/sdk-go/vela.(*Client).addAuthentication(0xc000125040, 0xc0000bd500)
/home/runner/go/pkg/mod/github.com/go-vela/[email protected]/vela/client.go:216 +0x12e
github.com/go-vela/sdk-go/vela.(*Client).NewRequest(0xc000125040, {0x2c722d5, 0x3}, {0xc0004ae810?, 0x10104c5?}, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/go-vela/[email protected]/vela/client.go:320 +0x24d
github.com/go-vela/sdk-go/vela.(*Client).Call(0x2c8e5d0?, {0x2c722d5?, 0xc000607490?}, {0xc0004ae810?, 0x2?}, {0x0?, 0x0?}, {0x2c32800, 0xc0001732c0})
/home/runner/go/pkg/mod/github.com/go-vela/[email protected]/vela/client.go:416 +0x3f
github.com/go-vela/sdk-go/vela.(*RepoService).Get(0xc00070e6b0, {0xc0004ae2e3?, 0x2c920c2?}, {0xc0004ae5f1, 0x6})
/home/runner/go/pkg/mod/github.com/go-vela/[email protected]/vela/repo.go:24 +0xf9
github.com/go-vela/cli/action/repo.(*Config).View(0xc000607580, 0xc000125040)
/home/runner/work/cli/cli/action/repo/view.go:22 +0x105
github.com/go-vela/cli/command/repo.view(0x402fa00?)
/home/runner/work/cli/cli/command/repo/view.go:104 +0x147
github.com/urfave/cli/v2.(*Command).Run(0x402fa00, 0xc000407b80, {0xc000065d60, 0x1, 0x1})
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:274 +0x998
github.com/urfave/cli/v2.(*Command).Run(0x402eae0, 0xc000407a40, {0xc00040a5a0, 0x2, 0x2})
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:267 +0xbe5
github.com/urfave/cli/v2.(*Command).Run(0xc0006a34a0, 0xc000407180, {0xc000110150, 0x3, 0x3})
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:267 +0xbe5
github.com/urfave/cli/v2.(*App).RunContext(0xc0003243c0, {0x2f907b8?, 0x407dd20}, {0xc000110150, 0x3, 0x3})
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:332 +0x5b7
github.com/urfave/cli/v2.(*App).Run(...)
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:309
main.main()
/home/runner/work/cli/cli/cmd/vela-cli/main.go:137 +0x10df