Skip to content

Conversation

@Flamefire
Copy link
Contributor

We can catch HTTPErrors and convert it to a EasyBuildError instead of letting it show up in main.
For the common 401 error indicating a token issue we can add a more useful message.

Without it it looks like this:

EasyBuild crashed! Please consider reporting a bug, this should not happen...

Traceback (most recent call last):
  File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/easybuild-framework/easybuild/main.py", line 843, in <module>
    main_with_hooks()
  File "/easybuild-framework/easybuild/main.py", line 829, in main_with_hooks
    sys.exit(int(main(args=args, prepared_cfg_data=(init_session_state, eb_go, cfg_settings))))
  File "/easybuild-framework/easybuild/main.py", line 780, in main
    is_successful = process_eb_args(orig_paths, eb_go, cfg_settings, modtool, testing, init_session_state,
  File "/easybuild-framework/easybuild/main.py", line 614, in process_eb_args
    test_report_msg = overall_test_report(ecs_with_res, len(paths), overall_success, success_msg, init_session_state)
  File "/easybuild-framework/easybuild/tools/testing.py", line 459, in overall_test_report
    txt = post_pr_test_report(pr_nrs, GITHUB_EASYCONFIGS_REPO, test_report, msg, init_session_state,
  File "/easybuild-framework/easybuild/tools/testing.py", line 362, in post_pr_test_report
    gist_url = upload_test_report_as_gist(test_report['full'], descr=descr, fn=fn)
  File "/easybuild-framework/easybuild/tools/testing.py", line 335, in upload_test_report_as_gist
    gist_url = create_gist(test_report, descr=descr, fn=fn, github_user=github_user)
  File "/easybuild-framework/easybuild/tools/github.py", line 839, in create_gist
    status, data = g.gists.post(body=body)
  File "/easybuild-framework/easybuild/base/rest.py", line 140, in post
    return self.request(self.POST, url, json.dumps(body), headers, content_type='application/json')
  File "/easybuild-framework/easybuild/base/rest.py", line 177, in request
    conn = self.get_connection(method, url, body, headers)
  File "/easybuild-framework/easybuild/base/rest.py", line 216, in get_connection
    connection = self.opener.open(request)
  File "/usr/lib64/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib64/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib64/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized

…nt failed.

We can catch `HTTPError`s and convert it to a `EasyBuildError` instead
of letting it show up in `main`.
For the common 401 error indicating a token issue we can add a more
useful message.
Copy link
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@boegel boegel added this to the next release (5.2.0) milestone Dec 3, 2025
@boegel boegel merged commit 889a06b into easybuilders:develop Dec 3, 2025
39 checks passed
@boegel boegel changed the title Show more readable error message when uploading gist or posting comment failed. Show more readable error message when uploading gist or posting comment failed Dec 3, 2025
@Flamefire Flamefire deleted the http-gist-error branch December 3, 2025 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants