Add ACTIONS_ORCHESTRATION_ID to user-agent string#695
Conversation
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
|
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 <1750815+TingluoHuang@users.noreply.github.com>
|
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 <1750815+TingluoHuang@users.noreply.github.com>
|
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
|
Hello from actions/github-script! (3ecadc4) |
|
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 <1750815+TingluoHuang@users.noreply.github.com>
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 <1750815+TingluoHuang@users.noreply.github.com>
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 <1750815+TingluoHuang@users.noreply.github.com>

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