ente-io / ente

Fully open source, End to End Encrypted alternative to Google Photos and Apple Photos
https://ente.io
GNU Affero General Public License v3.0
16.2k stars 835 forks source link

[CLI] Slice bounds out of Range when CLI export path one char long #3770

Open NotLe0n opened 1 month ago

NotLe0n commented 1 month ago

Description

When setting the export directory to a path which only has one character the cli panics:

PS C:\Users\leon> ente account add
Enter app type (default: photos):
Use default app type: photos
Enter export directory: .
panic: runtime error: slice bounds out of range [:2] with length 1

goroutine 1 [running]:
github.com/ente-io/cli/internal.ResolvePath({0xc000088184?, 0xc0001d3b10?})
        github.com/ente-io/cli/internal/promt.go:228 +0x99
github.com/ente-io/cli/internal.GetExportDir()
        github.com/ente-io/cli/internal/promt.go:180 +0x78
github.com/ente-io/cli/pkg.(*ClICtrl).AddAccount(0xc0001faea0, {0x8c74e8, 0xc0000220b8})
        github.com/ente-io/cli/pkg/account.go:27 +0xfa
github.com/ente-io/cli/cmd.glob..func2(0xbbe720?, {0x7d3932?, 0x0?, 0x0?})
        github.com/ente-io/cli/cmd/account.go:34 +0x33
github.com/spf13/cobra.(*Command).execute(0xbbe720, {0xc1d788, 0x0, 0x0})
        github.com/spf13/cobra@v1.7.0/command.go:944 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0xbbd020)
        github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.7.0/command.go:992
github.com/ente-io/cli/cmd.Execute(0xc0001faea0?, {0x8c1870?, 0x21?})
        github.com/ente-io/cli/cmd/root.go:40 +0x68

The responsible line is this one: https://github.com/ente-io/ente/blob/main/cli/internal/promt.go#L228

Version

cli-v0.2.1

What product are you using?

No response

What platform are you using?

Desktop - Windows

mngshm commented 3 weeks ago

Hey its more preferred to input Absolute path