Skip to content

Commit 8633f85

Browse files
authored
Merge pull request nf-core#2884 from nf-core/mesg_unauthorised__download_fail
Gives an error message if safe_get() returns 401 (wrong GITHUB_TOKEN?)
2 parents a6c2808 + 81d5509 commit 8633f85

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
### Download
2020

2121
- Replace `--tower` with `--platform`. The former will remain for backwards compatability for now but will be removed in a future release.
22+
- Better error message when GITHUB_TOKEN exists but is wrong/outdated
2223

2324
### Components
2425

nf_core/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ def __init__(self): # pylint: disable=super-init-not-called
454454
self.auth_mode = None
455455
self.return_ok = [200, 201]
456456
self.return_retry = [403]
457+
self.return_unauthorised = [401]
457458
self.has_init = False
458459

459460
def lazy_init(self):
@@ -546,6 +547,8 @@ def safe_get(self, url):
546547
raise e
547548
else:
548549
return r
550+
elif request.status_code in self.return_unauthorised:
551+
raise RuntimeError(f"GitHub API PR failed, probably due to an expired GITHUB_TOKEN.")
549552

550553
return request
551554

0 commit comments

Comments
 (0)