JakeWharton / JakeWharton/gitout

Cryptic error message if GitHub token is incorrect

Open
#23 1 comment 0 reactions 0 assignees View on GitHub
enhancement pr welcome
Dominant language
Kotlin
Stars
288
Forks
17
Avg merge
2h 12m
Merged PRs (30d)
19

Description

If you have leading/trailing space in token in config.toml (error in copy-pasting) i.e.
```
[github]
token = " TOKEN_HERE"
```
gitout
- will be able to get repositories information including private ones
- will crash when trying to clone first private repository it tries with cryptic error:
```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 34, message: "too many redirects or authentication replays" }', src/libcore/result.rs:1188:5
```

If token is incorrect in the other way then `gitout` crashes when trying to get repos info with
```
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /usr/src/rustc-1.41.0/src/libcore/macros/mod.rs:15:40
```

More helpful error message would be appreciated.
My api token is 40 hex characters.
I am not sure whether one could assert token format as there are probably no long-term guarantees in GitHub API.
I would assume there should be some endpoint which allows for easy checking whether provided token is correct. I checked that https://stackoverflow.com/a/58572011 seems to ignore extra spaces, haven't tried GraphQL API.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how the token from config.toml is used when fetching repository information and cloning private repositories. Reproduce both invalid-token cases, then replace the cryptic unwrap failures with helpful authentication errors; done means incorrect or whitespace-padded tokens fail without a panic.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, kotlin
Domain
authentication, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.