Skip to content

Get ros2.repos file using GitHub API with authentication#26

Merged
christophebedard merged 1 commit intomainfrom
christophebedard/get-ros2-repos-file-using-github-api
Jun 24, 2025
Merged

Get ros2.repos file using GitHub API with authentication#26
christophebedard merged 1 commit intomainfrom
christophebedard/get-ros2-repos-file-using-github-api

Conversation

@christophebedard
Copy link
Copy Markdown
Member

@christophebedard christophebedard commented Jun 24, 2025

I tried running ros-ci-for-pr and it failed when trying to fetch the ros2.repos file:

INFO:ros_github_scripts.ci_for_pr:Creating ros2.repos Gist for PRs
Traceback (most recent call last):
  File "/home/christophe.bedard/ros-tooling/ros-github-scripts/venv/bin/ros-ci-for-pr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/christophe.bedard/ros-tooling/ros-github-scripts/ros_github_scripts/ci_for_pr.py", line 433, in main
    gist = create_ci_gist(github_instance, chosen_pulls, parsed.target)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/christophe.bedard/ros-tooling/ros-github-scripts/ros_github_scripts/ci_for_pr.py", line 75, in create_ci_gist
    master_repos = fetch_repos(target_release)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/christophe.bedard/ros-tooling/ros-github-scripts/ros_github_scripts/ci_for_pr.py", line 65, in fetch_repos
    return toplevel_dict['repositories']
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'repositories'

The GET request (repos_response) was returning a 404. I think this is related to the changes GitHub has been making recently to unauthenticated requests, which is what we're currently doing. Since we already have a token, we can use that to make an authenticated request. I just used the github module to fetch the file.

This also includes #25: The branch of github.com/ros2/ros2 for the Rolling distro was changed from master to rolling some time ago (like most ROS 2 repos), so no need to use master for Rolling here.

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
@christophebedard
Copy link
Copy Markdown
Member Author

christophebedard commented Jun 24, 2025

@fujitatomoya if you've started getting the above error when running ros-ci-for-pr lately (since I know you use it), this should fix it.

Copy link
Copy Markdown
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me.

@christophebedard
Copy link
Copy Markdown
Member Author

I used these changes to trigger these CI jobs: ros2/ros2_tracing#187 (comment)

@christophebedard christophebedard merged commit da62b2f into main Jun 24, 2025
2 checks passed
@christophebedard christophebedard deleted the christophebedard/get-ros2-repos-file-using-github-api branch June 24, 2025 22:01
@fujitatomoya
Copy link
Copy Markdown
Contributor

@christophebedard i have never had this error yet, but thanks for the information. if i see those, i will upgrade the script.

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.

3 participants