-
Notifications
You must be signed in to change notification settings - Fork 37
Migrate Copilot engine from COPILOT_CLI_TOKEN to COPILOT_GITHUB_TOKEN with backward compatibility #3138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…tibility - Change primary token reference from COPILOT_CLI_TOKEN to COPILOT_GITHUB_TOKEN in copilot_engine.go - Add fallback to secrets.COPILOT_CLI_TOKEN for backward compatibility using || operator - Update secret validation to check for both COPILOT_GITHUB_TOKEN and COPILOT_CLI_TOKEN - Update trial command to use COPILOT_GITHUB_TOKEN while maintaining fallback support - Update all tests to verify both new and legacy token names - Update all documentation files to reflect the new token name - Update instruction files to document backward compatibility Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
| DD_SITE: ${{ secrets.DD_SITE || 'datadoghq.com' }} | ||
| GH_AW_MCP_CONFIG: /home/runner/.copilot/mcp-config.json | ||
| GITHUB_TOKEN: ${{ secrets.COPILOT_CLI_TOKEN }} | ||
| GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN || secrets.COPILOT_CLI_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Use COPILOT_GITHUB_TOKEN as it takes precedence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use COPILOT_GITHUB_TOKEN without fallback in the example. (f7eee63)
pkg/workflow/copilot_engine.go
Outdated
| "XDG_CONFIG_HOME": "/home/runner", | ||
| "COPILOT_AGENT_RUNNER_TYPE": "STANDALONE", | ||
| "GITHUB_TOKEN": "${{ secrets.COPILOT_CLI_TOKEN }}", | ||
| "GITHUB_TOKEN": "${{ secrets.COPILOT_GITHUB_TOKEN || secrets.COPILOT_CLI_TOKEN }}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot assign COPILOT_GITHUB_TOKEN var name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assigned to copilotGitHubToken variable for cleaner code organization. (f7eee63)
- Assign copilotGitHubToken variable for cleaner code (pkg/workflow/copilot_engine.go) - Update instruction file to use COPILOT_GITHUB_TOKEN without fallback (.github/instructions/http_mcp_headers.instructions.md) - All tests pass and workflows recompiled successfully Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot revert previous commit. The variable to store the secret should be COPILOT_GITHUB_TOKEN instead of GITHUB_TOKEN. Keep the backward compatible fallback to COPILOT_CLI_TOKEN |
- Rename env var key from GITHUB_TOKEN to COPILOT_GITHUB_TOKEN for clarity - Keep backward compatible fallback: COPILOT_GITHUB_TOKEN || COPILOT_CLI_TOKEN - Update instruction file to reflect the new env var name - All tests pass and workflows compile successfully Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Changed the environment variable name from |
|
@copilot fix tests |
- Update copilot_engine_test.go to verify COPILOT_GITHUB_TOKEN env var name - Test now checks for the correct environment variable after renaming from GITHUB_TOKEN - All tests pass successfully Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this 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 renames the Copilot engine secret from COPILOT_CLI_TOKEN to COPILOT_GITHUB_TOKEN across the codebase while maintaining backward compatibility with the legacy name. The change updates documentation, test expectations, workflow files, and CLI code to support both secret names with a fallback mechanism.
Key changes:
- Renamed primary secret from
COPILOT_CLI_TOKENtoCOPILOT_GITHUB_TOKEN - Added fallback support for legacy
COPILOT_CLI_TOKENname - Updated all documentation and instructional files
- Modified secret validation logic to check for either secret
Reviewed Changes
Copilot reviewed 53 out of 53 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/copilot_engine.go | Changed to use GenerateMultiSecretValidationStep with both secret names and updated environment variable to COPILOT_GITHUB_TOKEN with fallback |
| pkg/workflow/copilot_engine_test.go | Updated test expectations to check for new secret name with fallback syntax |
| pkg/workflow/secret_validation_test.go | Modified tests to validate both new and legacy secret names |
| pkg/workflow/redact_secrets_test.go | Updated test expectations to include both secret names in collection and validation |
| pkg/cli/trial_command.go | Changed secret name handling to use COPILOT_GITHUB_TOKEN while maintaining legacy support |
| docs/*.md | Updated all documentation to reference new secret name with backward compatibility notes |
| .github/workflows/*.lock.yml | Regenerated workflow files with new secret validation and environment variable setup |
| .github/instructions/*.md | Updated instruction files to reference new secret name |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Smoke Test Failure InvestigationThe Smoke OpenCode workflow failed on this PR due to a jq JSON parsing error when trying to configure OpenCode with MCP servers. The workflow attempted to transform the MCP configuration from gh-aw format to OpenCode format but encountered malformed JSON. Full Investigation Report - Run #84Failure Details
Root Cause AnalysisPrimary ErrorWhat Happened:
Root Cause:
Failed Jobs and ErrorsJob Sequence:
Error Location: Investigation FindingsContext of This PRThis PR is titled "Fix test to check for COPILOT_GITHUB_TOKEN instead of GITHUB_TOKEN" and updates a test in Why This Might Have Failed: Similar Historical PatternsI searched the investigation cache and found related MCP configuration issues:
However, this specific pattern (jq parse error for OpenCode MCP setup) has not been seen before in the investigation history. Recommended ActionsImmediate Investigation Needed
Fix OptionsOption 1: Add MCP Configuration Validation - name: Validate MCP Config
run: |
if [ -f "$GH_AW_MCP_CONFIG" ]; then
echo "Validating MCP configuration..."
jq empty "$GH_AW_MCP_CONFIG" || {
echo "::error::Invalid JSON in MCP configuration"
cat "$GH_AW_MCP_CONFIG"
exit 1
}
fiOption 2: Add Error Handling in OpenCode Setup Script # Before the jq transformation, validate the input
if ! jq empty "$GH_AW_MCP_CONFIG" 2>/dev/null; then
echo "::error::Invalid MCP configuration JSON"
echo "File contents:"
cat "$GH_AW_MCP_CONFIG"
exit 1
fiOption 3: Investigate Environment Variable Changes
Prevention Strategies
Technical DetailsError Context
Workflow Configuration
Environment
Next Steps
References:
|
|
@copilot merge main |
- Resolved conflict with smoke-copilot.firewall.lock.yml (deleted in main) - Merged latest changes from main branch - All tests pass successfully - All 66 workflows compile without errors Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Update Copilot Token Environment Variable Name
This PR updates the Copilot agentic engine to use
COPILOT_GITHUB_TOKENinstead ofCOPILOT_CLI_TOKENwhile maintaining backward compatibility.Recent Changes
COPILOT_GITHUB_TOKENenvironment variable name (instead ofGITHUB_TOKEN)GITHUB_TOKENtoCOPILOT_GITHUB_TOKENfor explicit clarity about token purposecopilotGitHubTokenvariable incopilot_engine.gofor better code maintainabilityCOPILOT_GITHUB_TOKENconsistentlyCore Implementation
COPILOT_GITHUB_TOKENorCOPILOT_CLI_TOKENCOPILOT_GITHUB_TOKEN(notGITHUB_TOKEN) uses fallback expression${{ secrets.COPILOT_GITHUB_TOKEN || secrets.COPILOT_CLI_TOKEN }}COPILOT_GITHUB_TOKENwith legacy supportBackward Compatibility
COPILOT_CLI_TOKENcontinue to work without modificationVerification
make agent-finishcompletes with 0 errorsCOPILOT_GITHUB_TOKENinstead of genericGITHUB_TOKENOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.