Add ACTIONS_ORCHESTRATION_ID to user-agent string#695
Conversation
Co-authored-by: TingluoHuang <[email protected]>
Co-authored-by: TingluoHuang <[email protected]>
Co-authored-by: TingluoHuang <[email protected]>
Co-authored-by: TingluoHuang <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
src/main.ts
Outdated
| * @param userAgent The base user agent string | ||
| * @returns The user agent string with orchestration ID appended if ACTIONS_ORCHESTRATION_ID is set | ||
| */ | ||
| function getUserAgentWithOrchestrationId(userAgent: string): string { |
package-lock.json
Outdated
| "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", | ||
| "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", | ||
| "dev": true, | ||
| "peer": true, |
Co-authored-by: TingluoHuang <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: TingluoHuang <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
src/main.ts
Outdated
| // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores | ||
| const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') |
There was a problem hiding this comment.
Updated to replace invalid characters with underscore instead of removing them in commit 135f4fc
Example: test@#$123 now becomes test___123 instead of test123
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot check CI failure and see if we need to fix our code or update the test |
There was a problem hiding this comment.
Pull request overview
This PR adds the ACTIONS_ORCHESTRATION_ID environment variable to the user-agent string when making GitHub API requests. The orchestration ID is sanitized to ensure it only contains valid characters (alphanumeric, dots, dashes, and underscores) before being appended to the user-agent string in the format orchestration-id/{sanitized_id}.
Key changes:
- Added
getUserAgentWithOrchestrationIdhelper function to read, sanitize, and append the orchestration ID to the user-agent string - Modified user-agent construction in
main()to always use a base user-agent and append orchestration ID when available - Applied sanitization that replaces invalid characters with underscores
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main.ts | Added getUserAgentWithOrchestrationId function and integrated it into the main function's user-agent construction logic |
| dist/index.js | Compiled JavaScript output reflecting the TypeScript changes in main.ts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: TingluoHuang <[email protected]>
Fixed the CI failure in commit c36bdc0. The Integration test was failing because when user-agent was explicitly set to an empty string, the code was defaulting to "actions/github-script" instead of using an empty string. Updated the logic to correctly distinguish between:
|
@copilot i think we should update the tests. |
Co-authored-by: TingluoHuang <[email protected]>
Updated the integration test in commit c0078b2 to expect 'actions/github-script' prefix even when user-agent is set to an empty string. Also simplified the user-agent logic to always default empty input to 'actions/github-script' for consistency. |
src/main.ts
Outdated
| // Sanitize orchestration ID - replace invalid characters with underscore | ||
| const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_') | ||
|
|
||
| return `${userAgent} orchestration-id/${sanitized}` |
Co-authored-by: TingluoHuang <[email protected]>
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/github-script](https://github.com/actions/github-script) | action | major | `v8.0.0` → `v9.0.0` | --- ### Release Notes <details> <summary>actions/github-script (actions/github-script)</summary> ### [`v9.0.0`](https://github.com/actions/github-script/releases/tag/v9.0.0) [Compare Source](actions/github-script@v8.0.0...v9.0.0) **New features:** - **`getOctokit` factory function** — Available directly in the script context. Create additional authenticated Octokit clients with different tokens for multi-token workflows, GitHub App tokens, and cross-org access. See [Creating additional clients with `getOctokit`](https://github.com/actions/github-script#creating-additional-clients-with-getoctokit) for details and examples. - **Orchestration ID in user-agent** — The `ACTIONS_ORCHESTRATION_ID` environment variable is automatically appended to the user-agent string for request tracing. **Breaking changes:** - **`require('@​actions/github')` no longer works in scripts.** The upgrade to `@actions/github` v9 (ESM-only) means `require('@​actions/github')` will fail at runtime. If you previously used patterns like `const { getOctokit } = require('@​actions/github')` to create secondary clients, use the new injected `getOctokit` function instead — it's available directly in the script context with no imports needed. - `getOctokit` is now an injected function parameter. Scripts that declare `const getOctokit = ...` or `let getOctokit = ...` will get a `SyntaxError` because JavaScript does not allow `const`/`let` redeclaration of function parameters. Use the injected `getOctokit` directly, or use `var getOctokit = ...` if you need to redeclare it. - If your script accesses other `@actions/github` internals beyond the standard `github`/`octokit` client, you may need to update those references for v9 compatibility. #### What's Changed - Add ACTIONS\_ORCHESTRATION\_ID to user-agent string by [@​Copilot](https://github.com/Copilot) in [#​695](actions/github-script#695) - ci: use deployment: false for integration test environments by [@​salmanmkc](https://github.com/salmanmkc) in [#​712](actions/github-script#712) - feat!: add getOctokit to script context, upgrade [@​actions/github](https://github.com/actions/github) v9, [@​octokit/core](https://github.com/octokit/core) v7, and related packages by [@​salmanmkc](https://github.com/salmanmkc) in [#​700](actions/github-script#700) #### New Contributors - [@​Copilot](https://github.com/Copilot) made their first contribution in [#​695](actions/github-script#695) **Full Changelog**: <actions/github-script@v8.0.0...v9.0.0> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMTAuMTIiLCJ1cGRhdGVkSW5WZXIiOiI0My4xMTAuMTMiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIiwibGFiZWxzIjpbXX0=--> Reviewed-on: https://codeberg.org/umati/Sample-Server/pulls/1678 Co-authored-by: umati-bot <[email protected]> Co-committed-by: umati-bot <[email protected]>

Implementation Plan
Changes Made
Updated orchestration ID format in
src/main.ts:orchestration-id/${sanitized}toactions_orchestration_id/${sanitized}Example user-agent string:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
https://github.com/github/actions-runtime/issues/5389