Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Plan: Add orchestration_id to git user-agent

Based on the reference PR (actions/toolkit#2229), I need to:

  • Update git-command-manager.ts to include orchestration ID in the GIT_HTTP_USER_AGENT
    • Add logic to check for ACTIONS_ORCHESTRATION_ID environment variable
    • Sanitize the orchestration ID (allow only: 0-9, a-z, _, -, .)
    • Append actions_orchestration_id/{sanitized_id} to the user agent if env var is set
    • Simplified validation to accept any non-empty sanitized value
  • Add tests for the new functionality
    • Test with orchestration ID set (with actual verification of user-agent content)
    • Test without orchestration ID set (with actual verification)
    • Test sanitization of invalid characters (with actual verification)
  • Run linter and build
  • Run tests to verify changes (94 tests passing)
  • Request code review (✅ No issues found)
  • Run security checks (✅ No vulnerabilities found)
  • Address review comments
    • Improved test assertions to verify actual user-agent content
    • Simplified empty ID handling per feedback
    • Removed test for edge case per feedback

Summary

This PR successfully implements orchestration ID support in the git user-agent for the checkout action. The implementation:

✅ Follows the same pattern as actions/toolkit#2229
✅ Sanitizes orchestration ID values for security (allows only: 0-9, a-z, _, -, .)
✅ Accepts any non-empty sanitized value
✅ Includes comprehensive test coverage (3 new tests with actual assertions, all passing)
✅ Passes all existing tests (94/94 passing)
✅ Passes linter and format checks
✅ Has no security vulnerabilities
✅ Has no code review issues

The git user-agent will now include actions_orchestration_id/{sanitized_id} when the ACTIONS_ORCHESTRATION_ID environment variable is set and results in a non-empty string after sanitization.


💡 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] Update user-agent to include orchestration_id when env is set Add orchestration_id to git user-agent when ACTIONS_ORCHESTRATION_ID is set Jan 8, 2026
Copilot AI requested a review from TingluoHuang January 8, 2026 14:53
@TingluoHuang TingluoHuang marked this pull request as ready for review January 8, 2026 15:01
Copilot AI review requested due to automatic review settings January 8, 2026 15:01
Copy link
Contributor

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 pull request adds support for appending an orchestration ID to the Git HTTP user-agent string when the ACTIONS_ORCHESTRATION_ID environment variable is set, matching the implementation in actions/toolkit#2229.

Key Changes:

  • Read ACTIONS_ORCHESTRATION_ID from environment variables and sanitize it to allow only alphanumeric characters, underscores, hyphens, and periods
  • Append the sanitized orchestration ID as actions_orchestration_id/{sanitized_id} to the Git HTTP user-agent
  • Add test coverage for orchestration ID presence, absence, and character sanitization scenarios

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/git-command-manager.ts Implements orchestration ID reading, sanitization, and user-agent construction logic
dist/index.js Compiled/transpiled version of the TypeScript changes
test/git-command-manager.test.ts Adds test cases for orchestration ID scenarios (present, absent, sanitization)
Comments suppressed due to low confidence (2)

test/git-command-manager.test.ts:468

  • Consider adding test coverage for edge cases such as an empty string orchestration ID (ACTIONS_ORCHESTRATION_ID="") and an orchestration ID that becomes empty after sanitization (e.g., ACTIONS_ORCHESTRATION_ID="()///"). These edge cases could result in malformed user-agent strings like "git/2.18 (github-actions-checkout) actions_orchestration_id/".
})

test/git-command-manager.test.ts:415

  • The test should verify that the GIT_HTTP_USER_AGENT environment variable is actually set correctly with the orchestration ID. Currently, it only verifies that the git command manager was created successfully, but doesn't assert that the user-agent contains "actions_orchestration_id/test-orch-id-12345". Consider inspecting the options.env parameter passed to mockExec to verify the environment variable is set as expected.
    // The user agent should be set with orchestration ID
    // We can't directly inspect gitEnv, but we verify the git command was created successfully
    expect(git).toBeDefined()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TingluoHuang
Copy link
Member

@copilot apply changes based on the comments in this thread

Copy link
Contributor Author

Copilot AI commented Jan 8, 2026

@copilot apply changes based on the comments in this thread

Applied all changes from the review comments. Tests now verify actual user-agent content, and the code properly handles empty orchestration IDs by checking for at least one alphanumeric character. All 95 tests passing. Commit: 4b87797

@TingluoHuang TingluoHuang merged commit 064fe7f into main Jan 8, 2026
12 checks passed
@TingluoHuang TingluoHuang deleted the copilot/update-user-agent-with-orchestration-id branch January 8, 2026 20:07
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.

4 participants