GitHub has started to roll out app tokens that are longer and break the validate_gh_pat() check.
|
if ( |
|
x == "" || |
|
# https://github.blog/changelog/2021-03-04-authentication-token-format-updates/ |
|
# Fine grained tokens start with "github_pat_". |
|
# https://github.blog/changelog/2022-10-18-introducing-fine-grained-personal-access-tokens/ |
|
grepl( |
|
"^(gh[pousr]_[A-Za-z0-9_]{36,251}|github_pat_[A-Za-z0-9_]{36,244})$", |
|
x |
|
) || |
|
grepl("^[[:xdigit:]]{40}$", x) |
|
) { |
|
x |
|
} else { |
|
url <- "https://gh.r-lib.org/articles/managing-personal-access-tokens.html" |
|
cli::cli_abort(c( |
|
"Invalid GitHub PAT format", |
|
"i" = "A GitHub PAT must have one of three forms:", |
|
"*" = "40 hexadecimal digits (older PATs)", |
|
"*" = "A 'ghp_' prefix followed by 36 to 251 more characters (newer PATs)", |
|
"*" = "A 'github_pat_' prefix followed by 36 to 244 more characters (fine-grained PATs)", |
|
"i" = "Read more at {.url {url}}." |
|
)) |
|
} |
|
} |
They say "The overall length of the tokens will be longer (520 characters) and will vary based on the data stored within it." The "" there is annoying, so I'm not sure EXACTLY what should be allowed, but something along these lines should work:
if (
x == "" ||
# https://github.blog/changelog/2021-03-04-authentication-token-format-updates/
# Fine grained tokens start with "github_pat_".
# https://github.blog/changelog/2022-10-18-introducing-fine-grained-personal-access-tokens/
grepl(
"^(gh[pousr]_[A-Za-z0-9_]{36,251}|github_pat_[A-Za-z0-9_]{36,244}|ghs_[A-Za-z0-9_]+)$",
x
) ||
grepl("^[[:xdigit:]]{40}$", x)
) {
x
} else {
url <- "https://gh.r-lib.org/articles/managing-personal-access-tokens.html"
cli::cli_abort(c(
"Invalid GitHub PAT format",
"i" = "A GitHub PAT must have one of four forms:",
"*" = "40 hexadecimal digits (older PATs)",
"*" = "A 'ghp_' prefix followed by 36 to 251 more characters (newer PATs)",
"*" = "A `ghs_` prefix followed by about 500 characters (GitHub App installation tokens)",
"*" = "A 'github_pat_' prefix followed by 36 to 244 more characters (fine-grained PATs)",
"i" = "Read more at {.url {url}}."
))
}
}
I'm seeing sporadic failures on GitHub Actions that look like they are caused by this.
I'll submit a PR shortly.
GitHub has started to roll out app tokens that are longer and break the
validate_gh_pat()check.gh/R/gh_token.R
Lines 93 to 116 in e9194ae
They say "The overall length of the tokens will be longer (
520 characters) and will vary based on the data stored within it." The "" there is annoying, so I'm not sure EXACTLY what should be allowed, but something along these lines should work:I'm seeing sporadic failures on GitHub Actions that look like they are caused by this.
I'll submit a PR shortly.