feat: add User-Agent header to all GitHub API calls#433
Open
Dipro-cyber wants to merge 1 commit into
Open
Conversation
Contributor
|
Can you fix the merge conflicts? Also I'm not sure that the strategy of importing from the metadata file is going to work. It was tried when we rolled out #322 and we ended up backtracking on using the version number because the imports were complaining about importing something from outside the module or something. #251 i think was the issue created as a result of this problem |
Contributor
|
we might need to find a way to resolve that metadata problem before this PR will be possible. I think the version number is somewhat more important to include in the user agent than the database connection args. |
- Moves get_user_agent() into collectoss/util/version.py using importlib.metadata to read the version, avoiding the metadata.py import-outside-module issue (chaoss#251/chaoss#322) - Falls back to 'unknown' if the package is not installed - Updates github_graphql_data_access.py to use new import path and resolves merge conflicts with upstream changes to that file Signed-off-by: Diptesh Roy <droy88333@gmail.com>
5c3f96c to
3cf1051
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
User-Agentheader to all outgoing GitHub API requests so GitHubcan identify traffic from CollectOSS tooling. This helps with bot
detection, allows GitHub staff to reach out if needed, and will benefit
future support for other forge instances (Forgejo etc.).
The User-Agent format is:
CollectOSS/1.0.0 (github:chaoss/collectoss; CHAOSS/Linux Foundation)A
get_user_agent()helper is added tometadata.pyso the versionnumber stays in sync with the project version automatically. Applied in:
github_data_access.py(REST API — primary path)github_graphql_data_access.py(GraphQL API)github_api_key_handler.py(key validation calls)github_paginator.py(deprecatedhit_apipath)This PR fixes #408
Notes for Reviewers
No logic changes — purely additive header injection. The
get_user_agent()helper in
metadata.pymakes the version easy to update in one place.Signed commits
Generative AI disclosure