Add actions_orchestration_id as part of user-agent#12433
Add actions_orchestration_id as part of user-agent#12433TingluoHuang wants to merge 1 commit intocli:trunkfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the HTTP client to include the ACTIONS_ORCHESTRATION_ID environment variable in the User-Agent header for better tracking of requests from GitHub Actions workflows. The orchestration ID is sanitized to ensure only valid characters (alphanumeric, underscores, hyphens, and dots) are included.
- Implements a new
getUserAgentForActionsfunction that sanitizes and appends the orchestration ID to the User-Agent - Adds comprehensive unit tests covering various scenarios including special character sanitization
- Integrates the new functionality into the existing
NewHTTPClientfunction
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| api/http_client.go | Adds getUserAgentForActions function to append sanitized orchestration ID to User-Agent header |
| api/http_client_test.go | Adds comprehensive unit tests for the new functionality including sanitization and integration tests |
Comments suppressed due to low confidence (1)
api/http_client_test.go:363
- Using os.Unsetenv in tests can cause race conditions when tests run in parallel, as environment variables are process-global. The test should use t.Setenv with an empty string or ensure tests don't run in parallel. Since t.Setenv is used in other test cases, it should be used consistently here as well.
os.Unsetenv("ACTIONS_ORCHESTRATION_ID")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @TingluoHuang! I am going to switch this to a draft for now since we have some internal discussions about this and it can't be reviewed yet 🙏 I think we should discuss this more at some point to understand what the blockers are internally. |
Fixes: #12430
This pull request enhances the way the HTTP client sets the
User-Agentheader by allowing it to include a sanitized orchestration ID from the environment variableACTIONS_ORCHESTRATION_ID. This helps with tracking and debugging requests originating from orchestrated GitHub Actions workflows. The changes also include comprehensive tests to ensure correct behavior and sanitization of the orchestration ID.