Skip to content

git_sitrep() works again without error if token is expired#2014

Closed
olivroy wants to merge 1 commit intor-lib:mainfrom
olivroy:cli-git-sitrep
Closed

git_sitrep() works again without error if token is expired#2014
olivroy wants to merge 1 commit intor-lib:mainfrom
olivroy:cli-git-sitrep

Conversation

@olivroy
Copy link
Copy Markdown
Contributor

@olivroy olivroy commented Jul 2, 2024

@jennybc this is a fix to a regression that is caused by the switch to cli.

Basically, this removes some elements to the message object, since it contains many things that should not be printed.

usethis::git_sitrep()

usethis 2.2.3
image
Current main
image
This PR
image
Doesn't show Error in gh():

While working on this workaround fix, I saw another issue (not fixed).

The bullets are not properly formatted if a token is missing, but couldn't figure out how to fix this.

I'd recommend you running usethis::git_sitrep() with an expired token to notice it.

Issue I am noticing (not addressed)
image

@olivroy olivroy changed the title print git_sitrep() without error if token is absent git_sitrep() works again without error if token is absent Jul 2, 2024
@jennybc
Copy link
Copy Markdown
Member

jennybc commented Jul 6, 2024

While working on this workaround fix, I saw another issue (not fixed).

Can you open a separate issue about that, so we don't lose track of it?

@jennybc
Copy link
Copy Markdown
Member

jennybc commented Jul 6, 2024

I can't seem to reproduce the problem.

I just installed from main and deleted my PAT from the credential store. Here's what I see:

> git_sitrep()

── Git global (user) 
• Name: "Jenny Bryan"
• Email: "jenny.f.bryan@gmail.com"
• Global (user-level) gitignore file: ~/.gitignore_global
• Vaccinated: TRUE
• Default Git protocol: ℹ Defaulting to "https" Git protocol. "https"
• Default initial branch name: "main"

── GitHub user 
• Default GitHub host: "https://github.com"
• Personal access token for "https://github.com": <unset>
☐ To create a personal access token, call `create_github_token()`.
☐ To store a token for current and future use, call `gitcreds::gitcreds_set()`.
ℹ Read more in the Managing Git(Hub) Credentials article.

...

Do you understand why we are having such a different experience?

@olivroy
Copy link
Copy Markdown
Contributor Author

olivroy commented Jul 6, 2024

I have rlang::global_entrace() enabled in my .Rprofile

@jennybc
Copy link
Copy Markdown
Member

jennybc commented Jul 6, 2024

So do I:

if (requireNamespace("rlang", quietly = TRUE)) {
    options(error = rlang::entrace, rlang_backtrace_on_error = "reminder")
}

Are you sure this isn't about scopes for the token? I don't see how this can be about the token being absent.

@olivroy olivroy changed the title git_sitrep() works again without error if token is absent git_sitrep() works again without error if token is expired Jul 17, 2024
@olivroy
Copy link
Copy Markdown
Contributor Author

olivroy commented Jul 18, 2024

@jennybc

I encountered this again. And to be clear, this only happens when the token is expired, not absent. (i.e. received multiple emails about his and ignored them)
I create my token with usethis, so the permissions should be quite standard.

I updated my PR's title.

I guess that to experience this yourself, the best way would be to do.

Set the expiration date to tomorrow.
image

Add this token with gitcreds::gitcreds_set()

And call usethis::git_sitrep() tomorrow.

@jennybc
Copy link
Copy Markdown
Member

jennybc commented Jul 18, 2024

Ok yeah absent and expired are pretty different!

@jennybc
Copy link
Copy Markdown
Member

jennybc commented Jul 23, 2024

I found a simpler solution to this. I think this was just a think-o that probably predated the switch to cli.

@jennybc jennybc closed this in bd37993 Jul 23, 2024
@jennybc
Copy link
Copy Markdown
Member

jennybc commented Jul 23, 2024

What you see now with an expired token:

── GitHub user 
• Default GitHub host: "https://github.com"
• Personal access token for "https://github.com": <discovered>
✖ Can't get user information for this token.
ℹ The token may no longer be valid or perhaps it lacks the "user" scope.
ℹ GitHub API error (401): Bad credentials

@olivroy olivroy deleted the cli-git-sitrep branch March 4, 2025 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants