Skip to content

feat(api-proxy): forward COPILOT_INTEGRATION_ID from host env#5147

Open
lpcox wants to merge 2 commits into
mainfrom
feat/copilot-integration-id-override
Open

feat(api-proxy): forward COPILOT_INTEGRATION_ID from host env#5147
lpcox wants to merge 2 commits into
mainfrom
feat/copilot-integration-id-override

Conversation

@lpcox

@lpcox lpcox commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds support for forwarding COPILOT_INTEGRATION_ID environment variable from host to api-proxy container, allowing consumers to override the default 'agentic-workflows' integration ID when needed for specific model allowlists or other integration requirements.

Implementation

  • Forward COPILOT_INTEGRATION_ID from --env, --env-file, or host env (with --env-all)
  • Trim and validate the value (ignore empty/whitespace-only values)
  • Fall back to api-proxy's default 'agentic-workflows' when unset
  • Do NOT forward GITHUB_COPILOT_INTEGRATION_ID (remains unused)

Testing

Added 7 new test cases covering:

  • ✅ Forwarding when explicitly set (host env with --env-all)
  • ✅ Not setting when empty string
  • ✅ Not setting when whitespace-only
  • ✅ Trimming surrounding whitespace
  • ✅ Not setting when nothing is set
  • ✅ Forwarding from --env flag (config.additionalEnv)
  • ✅ Preferring --env over host env

All unit tests pass.

Why This Approach

This is intentionally undocumented for limited use cases:

  1. Not in schema - Only accessible via env var or --env CLI flag, not stdin config
  2. Not documented - Won't be added to README or docs/environment.md
  3. Direct communication - We'll provide this directly to the user who needs it via private channel

Usage

Users can set it via --env flag:

awf --env COPILOT_INTEGRATION_ID=copilot-developer-cli --allow-domains api.githubcopilot.com ...

Or via host env with --env-all:

export COPILOT_INTEGRATION_ID=copilot-developer-cli
awf --env-all --allow-domains api.githubcopilot.com ...

Or in GitHub Actions:

env:
  COPILOT_INTEGRATION_ID: copilot-developer-cli

Add support for forwarding COPILOT_INTEGRATION_ID environment variable
from host to api-proxy container. This allows consumers to override the
default 'agentic-workflows' integration ID when needed for specific
model allowlists or other integration requirements.

Implementation:
- Forward COPILOT_INTEGRATION_ID from host env if explicitly set
- Trim and validate the value (ignore empty/whitespace-only values)
- Fall back to api-proxy's default 'agentic-workflows' when unset

This is intentionally undocumented for limited use cases only.

Closes #5132

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 17, 2026 04:00
@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 97.30% 97.34% 📈 +0.04%
Statements 97.16% 97.20% 📈 +0.04%
Functions 98.84% 98.84% ➡️ +0.00%
Branches 91.92% 91.96% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.7% → 94.5% (+1.82%) 92.7% → 94.5% (+1.82%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Not ready to approve

There’s a mismatch between the claimed --env support and the current implementation plus a test reliability issue due to incomplete env cleanup in existing tests.

Pull request overview

Adds an opt-in mechanism for callers to override the api-proxy’s default Copilot integration ID (agentic-workflows) by forwarding COPILOT_INTEGRATION_ID into the api-proxy container (with trimming and whitespace-only suppression), plus unit tests to validate the forwarding behavior.

Changes:

  • Forward COPILOT_INTEGRATION_ID into the api-proxy container only when it’s non-empty after trimming.
  • Keep GITHUB_COPILOT_INTEGRATION_ID intentionally un-forwarded.
  • Add Jest coverage for set/empty/whitespace/trim/unset cases.
File summaries
File Description
src/services/api-proxy-service-config.ts Adds conditional forwarding of COPILOT_INTEGRATION_ID into the api-proxy container env.
src/services/api-proxy-service-api-targets.test.ts Adds unit tests validating forwarding/omission behavior for COPILOT_INTEGRATION_ID.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


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

Comment on lines +125 to +127
...(process.env.COPILOT_INTEGRATION_ID?.trim() && {
COPILOT_INTEGRATION_ID: process.env.COPILOT_INTEGRATION_ID.trim(),
}),
Comment on lines +544 to +548
it('should forward COPILOT_INTEGRATION_ID from host env when explicitly set', () => {
const origCopilot = process.env.COPILOT_INTEGRATION_ID;
const origGhCopilot = process.env.GITHUB_COPILOT_INTEGRATION_ID;
process.env.COPILOT_INTEGRATION_ID = 'my-custom-integration';
delete process.env.GITHUB_COPILOT_INTEGRATION_ID;
@lpcox

lpcox commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

@github-actions

Copy link
Copy Markdown
Contributor

⏳ Copilot review left inline comments.

@lpcox To proceed:

  1. Ask @copilot to address the review feedback (reply to this comment or the review thread)
  2. Once the fix is pushed, add the ready-for-aw label to trigger agentic CI smoke tests

- Use getConfigEnvValue() to support --env/--env-file/--env-all for COPILOT_INTEGRATION_ID
- Add describe-level beforeEach/afterEach to prevent test flakiness
- Add tests for additionalEnv support and precedence
- All 9 tests in COPILOT_INTEGRATION_ID forwarding suite passing

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Review feedback addressed in commit f8a1456:

  1. ✅ Added support for --env flag via config.additionalEnv - now uses getConfigEnvValue() which properly prioritizes --env > --env-file > host env (with --env-all)
  2. ✅ Centralized environment cleanup - added describe-level beforeEach/afterEach to prevent test flakiness from host environment variables

All 9 tests in the COPILOT_INTEGRATION_ID forwarding suite are passing, including 2 new tests that verify --env support and precedence.

Copilot finished work on behalf of lpcox June 17, 2026 04:11
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