Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 6, 2026

Implementation Plan

  • Review the codebase and understand current user-agent handling
  • Add function to read and sanitize ACTIONS_ORCHESTRATION_ID environment variable
  • Modify main.ts to append orchestration ID to user-agent when available
  • Build and verify the changes work correctly
  • Run all tests to ensure no regressions
  • Apply code formatting and finalize changes
  • Add underscore to valid characters (0-9, a-z, A-Z, _, -, .)
  • Move getUserAgentWithOrchestrationId helper to end of file
  • Revert package-lock.json changes that added "peer": true flags
  • Replace invalid characters with underscore instead of removing them
  • Simplify user-agent logic: always default empty input to 'actions/github-script'
  • Remove unreachable code in getUserAgentWithOrchestrationId
  • Update integration test to expect new default behavior
  • Change format from orchestration-id to actions_orchestration_id

Changes Made

Updated orchestration ID format in src/main.ts:

  • Changed from orchestration-id/${sanitized} to actions_orchestration_id/${sanitized}
  • This aligns with the expected naming convention

Example user-agent string:

actions/github-script actions_orchestration_id/5b37aec4-4d4a-4be1-8756-c1adf0e55d26 octokit-core.js/5.0.1 Node.js/24

💡 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

Copilot AI changed the title [WIP] Read environment variable and append to user-agent Add ACTIONS_ORCHESTRATION_ID to user-agent string Jan 6, 2026
Copilot AI requested a review from TingluoHuang January 6, 2026 21:17
Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

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:

  • iojs.org
    • Triggering command: /usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - (dns block)

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 {
Copy link
Member

Choose a reason for hiding this comment

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

@copilot move the helper method to the end of the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the helper method to the end of the file in commit 8a9be95

"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz",
"integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==",
"dev": true,
"peer": true,
Copy link
Member

Choose a reason for hiding this comment

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

@copilot why we need this? please undo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted package-lock.json changes in commit 8a9be95. The "peer": true flags were added by npm during the initial setup and are not needed.

Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

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:

  • iojs.org
    • Triggering command: /usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

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:

  • iojs.org
    • Triggering command: /usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

src/main.ts Outdated
Comment on lines 114 to 115
// Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
Copy link
Member

Choose a reason for hiding this comment

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

@copilot replace invalid string with _

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to replace invalid characters with underscore instead of removing them in commit 135f4fc

Example: test@#$123 now becomes test___123 instead of test123

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Hello from actions/github-script! (3ecadc4)

@TingluoHuang TingluoHuang requested a review from a team as a code owner January 6, 2026 22:47
Copilot AI review requested due to automatic review settings January 6, 2026 22:47
Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

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:

  • iojs.org
    • Triggering command: /usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@TingluoHuang
Copy link
Member

@copilot check CI failure and see if we need to fix our code or update the test

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 getUserAgentWithOrchestrationId helper 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.

Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

@copilot check CI failure and see if we need to fix our code or update the test

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:

  • Empty string input → use empty string (no prefix)
  • No input provided → default to "actions/github-script"

Copilot AI temporarily deployed to debug-integration-test January 6, 2026 22:59 Inactive
@TingluoHuang
Copy link
Member

@copilot check CI failure and see if we need to fix our code or update the test

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:

  • Empty string input → use empty string (no prefix)
  • No input provided → default to "actions/github-script"

@copilot i think we should update the tests.

Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

@copilot check CI failure and see if we need to fix our code or update the test

Fixed the CI failure in commit [c36bdc0](c36bdc0a3af49bb7e233...

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.

Copilot AI temporarily deployed to debug-integration-test January 6, 2026 23:09 Inactive
@TingluoHuang
Copy link
Member

image

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}`
Copy link
Member

Choose a reason for hiding this comment

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

@copilot should be actions_orchestration_id/${sanitized}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the format to actions_orchestration_id/${sanitized} in commit b67a972.

Copilot AI requested a review from TingluoHuang January 7, 2026 04:18
Copilot AI temporarily deployed to debug-integration-test January 7, 2026 05:02 Inactive
@TingluoHuang TingluoHuang merged commit 450193c into main Jan 7, 2026
14 checks passed
@TingluoHuang TingluoHuang deleted the copilot/add-orchestration-id-user-agent branch January 7, 2026 15:23
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