Skip to content

Fixes for GitHub API access #4102

@chrisbillowsMO

Description

@chrisbillowsMO

Fixes/improvements for the use of the GitHub API for fetching commit information for the HTML report, (ref: #4036/#4075)

  1. Revise how the token passed into the environment
  2. When a token is missing, the try/except does not catch the HTTP error (e.g. see below). If there is a problem with the token/API etc then the report should still generate, just without the commit information.
Traceback (most recent call last):
  File "/home/b/b382148/cylc-run/recipe_test_workflow_production/run2/app/generate_report/bin/fetch_commit_info.py", 
line 96, in make_api_call
    raise requests.exceptions.HTTPError(
    ...<2 lines>...
    )
requests.exceptions.HTTPError: Unexpected status code for url=https://api.github.com/repos/ESMValGroup/ESMValCore/com
mits/71604c36 headers={'authorization': 'token None', 'accept': 'application/vnd.github+json'} params=None - 401: {"m
essage":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/b/b382148/cylc-run/recipe_test_workflow_production/run2/app/generate_report/bin/generate_html_report.py
", line 491, in <module>
    main()
    ~~~~^^
  File "/home/b/b382148/cylc-run/recipe_test_workflow_production/run2/app/generate_report/bin/generate_html_report.py
", line 132, in main
    commit_info = fetch_commit_details_from_github_api(sha_info)
  File "/home/b/b382148/cylc-run/recipe_test_workflow_production/run2/app/generate_report/bin/fetch_commit_info.py", 
line 46, in fetch_commit_details_from_github_api
    raw_commits = fetch_single_commit(
        package, "ESMValGroup", headers, shas_by_day["today"]
    )
  File "/home/b/b382148/cylc-run/recipe_test_workflow_production/run2/app/generate_report/bin/fetch_commit_info.py", 
line 141, in fetch_single_commit
    response = make_api_call(url, headers=headers)
  File "/home/b/b382148/cylc-run/recipe_test_workflow_production/run2/app/generate_report/bin/fetch_commit_info.py", 
line 101, in make_api_call
    raise requests.exceptions.HTTPError(
        f"HTTP error occurred: {http_err}"
    ) from http_err
requests.exceptions.HTTPError: HTTP error occurred: Unexpected status code for url=https://api.github.com/repos/ESMVa
lGroup/ESMValCore/commits/71604c36 headers={'authorization': 'token None', 'accept': 'application/vnd.github+json'} p
arams=None - 401: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}
[FAIL] set -euo pipefail
[FAIL] source set_container_versions.sh
[FAIL] env-file generate_html_report.py
[FAIL] if [ "${PRODUCTION}" = "True" ]; then rsync -av "${REPORT_PATH}" "${VM_PATH}"; echo "HTML report copied from $
{REPORT_PATH} to ${VM_PATH}"; fi # return-code=1
2025-06-27T13:45:39Z CRITICAL - failed/ERR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions