Skip to content

refactor: deduplicate OIDC auth env var mappings via shared constant - #5640

Merged
lpcox merged 2 commits into
mainfrom
refactor/dry-api-proxy-env-matrix-5621
Jun 28, 2026
Merged

lpcox merged 2 commits into
mainfrom
refactor/dry-api-proxy-env-matrix-5621

Conversation

@lpcox

@lpcox lpcox commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Eliminate ~40 repeated OIDC env/config mappings between build-config.ts and api-proxy-env-config.ts by introducing a shared OIDC_AUTH_ENV_MAPPING constant.

Changes

  • src/api-proxy-env-constants.ts: Added OIDC_AUTH_ENV_MAPPING (config field ↔ env var pairs) and OIDC_AUTH_ENV_VARS (env var name array)
  • src/commands/build-config.ts: Uses mapping to generate config from env/options
  • src/services/api-proxy-env-config.ts: Uses OIDC_AUTH_ENV_VARS for pickEnvVars() and OIDC_AUTH_ENV_MAPPING for config→env projection

Benefits

  • Single source of truth for OIDC auth env vars on the security-critical credential path
  • Adding a new OIDC provider requires editing only the constant array
  • Net reduction of ~8 lines despite added infrastructure

Testing

  • All api-proxy-env and oidc tests pass (54 tests)
  • TypeScript compiles cleanly

Closes #5621

Add OIDC_AUTH_ENV_MAPPING and OIDC_AUTH_ENV_VARS to api-proxy-env-constants.ts
as the single source of truth for the config-field↔env-var relationships.

Updated consumers:
- build-config.ts: uses OIDC_AUTH_ENV_MAPPING to populate config from env/options
- api-proxy-env-config.ts: uses OIDC_AUTH_ENV_VARS for pickEnvVars and
  OIDC_AUTH_ENV_MAPPING for config→env projection

This eliminates ~40 repeated env/config mappings on the credential path.

Closes #5621

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

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.25% 98.29% 📈 +0.04%
Statements 98.17% 98.21% 📈 +0.04%
Functions 99.53% 99.53% ➡️ +0.00%
Branches 94.00% 94.30% 📈 +0.30%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/commands/build-config.ts 93.3% → 94.4% (+1.11%) 93.3% → 94.4% (+1.11%)
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.

Pull request overview

This PR reduces duplication on the API-proxy/OIDC credential path by introducing a shared mapping for OIDC auth config fields ↔ environment variables, then reusing that mapping when (1) building WrapperConfig and (2) projecting config/env into the api-proxy sidecar environment.

Changes:

  • Add shared OIDC auth descriptors (OIDC_AUTH_ENV_MAPPING) and derived env var list (OIDC_AUTH_ENV_VARS).
  • Refactor build-config.ts to populate OIDC-related WrapperConfig fields from env/CLI using the shared mapping.
  • Refactor api-proxy-env-config.ts to forward OIDC env vars and apply config→env overrides using the shared mapping.
Show a summary per file
File Description
src/api-proxy-env-constants.ts Introduces shared OIDC auth mapping/constants to serve as a single source of truth.
src/commands/build-config.ts Uses the shared mapping to assemble OIDC-related config fields from CLI/env inputs.
src/services/api-proxy-env-config.ts Uses the shared mapping/list to forward OIDC env vars and apply config-file overrides when building sidecar env.

Review details

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread src/api-proxy-env-constants.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

Contribution guidelines check complete for PR #5640: all applicable CONTRIBUTING.md requirements appear satisfied; no comment needed.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

  • API status: ✅ PASS
  • gh check: ✅ PASS
  • File status: ✅ PASS

Overall result: PASS

Generated by Smoke Claude for #5640 · 36.1 AIC · ⊞ 3.3K ·

@github-actions

Copy link
Copy Markdown
Contributor

🔥 AWF Smoke Test — Auth mode: PAT (COPILOT_GITHUB_TOKEN)

Test Result
GitHub MCP connectivity
GitHub.com HTTP connectivity
File write/read

Overall: PASS

cc @lpcox

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK ✅

  • ✅ GitHub MCP: Connected
  • ✅ GitHub.com Connectivity: HTTP 200
  • ✅ File Write/Read: Test passed
  • ✅ BYOK Inference: Direct mode (COPILOT_PROVIDER_API_KEY) via api-proxy → api.githubcopilot.com

Status: PASS | Mode: Direct BYOK

cc @lpcox

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

🔥 Smoke Test Results — PR #5640

PR: refactor: deduplicate OIDC auth env var mappings via shared constant
Author: @lpcox

Test Result
GitHub MCP connectivity
GitHub.com HTTP ✅ 200
File write/read ⚠️ Pre-step data unavailable (template vars unresolved)

Overall: PASS (2/2 verifiable tests passed)

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox

  • MCP connectivity: ✅
  • GitHub.com connectivity: ✅
  • File write/read: ✅
  • BYOK inference: ✅

Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra

Overall: PASS

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

Copy link
Copy Markdown
Contributor

refactor: deduplicate OIDC auth env var mappings via shared constant
fix: only count inference calls against maxRuns limit
chore: upgrade gh-aw to v0.81.6 and recompile all workflows
GitHub PR query: ✅
GitHub CLI query: ✅
GitHub homepage title: ✅
Smoke file write: ✅
Discussion comment: ✅
Build: ✅
Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

🔭 Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Detail
1. Module Loading otel.js loads and exports 7 public functions: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled
2. Test Suite OTEL tests exist — otel.test.js (39 tests), otel-fanout.test.js (20 tests); no unexpected failures found
3. Env Var Forwarding src/services/api-proxy-env-config.ts forwards 5 OTEL env vars to api-proxy: GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID, plus OTEL_SERVICE_NAME
4. Token Tracker Integration onUsage callback exists in token-tracker-http.js (lines 283, 324, 326, 374) — invoked after normalized usage extraction, serving as the OTEL hook point
5. OTEL Diagnostics Export path is wired: FileSpanExporter fallback to /var/log/api-proxy/otel.jsonl when no OTLP endpoint configured; ProxyAwareOtlpExporter / FanOutSpanExporter for live endpoints via Squid

All scenarios pass. OTEL tracing integration is fully implemented and tested. This PR's OIDC refactor does not affect the OTEL code paths.

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3 ❌ NO
Node.js v24.17.0 v22.23.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environment.

Tested by Smoke Chroot

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for #5640 · 38.8 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

Gemini Engine Smoke Test Results

  • PR Titles: N/A (Failed to retrieve)
  • GitHub MCP Testing: ❌
  • GitHub.com Connectivity: ❌
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions

Copy link
Copy Markdown
Contributor

refactor: deduplicate OIDC auth env var mappings via shared constant

MCP connectivity: ✅
GitHub.com connectivity: ✅
File I/O: ✅
BYOK inference: ✅

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)

Overall: PASS

CC @lpcox

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity

Check Result
Redis PING (host.docker.internal:6379) ❌ Timeout
PostgreSQL pg_isready (host.docker.internal:5432) ❌ No response
PostgreSQL SELECT 1 ❌ Timeout

Overall: FAIL

All checks timed out. The AWF agent container (172.30.0.20) has host.docker.internal172.17.0.1 in /etc/hosts, but iptables rules block database/cache ports (6379, 5432) as part of the firewall policy.

🔌 Service connectivity validated by Smoke Services

@lpcox
lpcox merged commit ebbdcab into main Jun 28, 2026
88 checks passed
@lpcox
lpcox deleted the refactor/dry-api-proxy-env-matrix-5621 branch June 28, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Duplicate Code] API proxy environment variable matrix is duplicated between host config and sidecar env

2 participants