Improve validation of user provided path

Open Beginner friendly
#9 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
go
Domain
cli

Research direction

Start in cmd/install.go around line 39 and internal/discord/paths.go around line 78 to trace how --path is checked against discovered paths. Reproduce the shown bdcli install command, then inspect how package.json existence or content can validate the supplied path. Done means a valid manual path is accepted when internal path resolution fails, while invalid paths still produce the existing error.

Written by the indexing model from the issue text.

Description

Currently bdcli expected the --path given by user matched in the discovered list of paths

https://github.com/BetterDiscord/cli/blob/a933d312d632af0eeb64a7c167dcdd7c9951ef04/cmd/install.go#L39

https://github.com/BetterDiscord/cli/blob/a933d312d632af0eeb64a7c167dcdd7c9951ef04/internal/discord/paths.go#L78

Which causing manual path would fail when the internal path resolution failed

$ bdcli install -p ~/.config/discord/app-1.0.137/modules/discord_desktop_core-1/discord_desktop_core/
Error: could not find a valid Discord installation at ***/.config/discord/app-1.0.137/modules/discord_desktop_core-1/discord_desktop_core/
Usage:
  bdcli install [flags]

Aliases:
  install, reinstall

Flags:
  -c, --channel string   Discord release channel (stable|ptb|canary) (default "stable")
  -h, --help             help for install
  -p, --path string      Path to a Discord installation

Global Flags:
      --silent   Suppress non-error output

could not find a valid Discord installation at ***/.config/discord/app-1.0.137/modules/discord_desktop_core-1/discord_desktop_core/

Suggestion:

Validate the --path by checking the existence of package.json or even the content of it

Related to: https://github.com/BetterDiscord/cli/issues/8#issuecomment-4393432539

Dominant language
Go
Stars
22
Forks
3
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BetterDiscord/cli

All issues in BetterDiscord/cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.