Skip to content

refactor: extract shared OIDC refresh/sleep utilities#2811

Merged
lpcox merged 1 commit into
mainfrom
refactor/oidc-shared-refresh
May 9, 2026
Merged

refactor: extract shared OIDC refresh/sleep utilities#2811
lpcox merged 1 commit into
mainfrom
refactor/oidc-shared-refresh

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented May 9, 2026

Summary

Extracts duplicated _scheduleRefresh() and _sleep() methods from AwsOidcTokenProvider and GcpOidcTokenProvider into a shared oidc-refresh-utils.js module.

Problem

Both OIDC token providers had identical 20-line _scheduleRefresh() methods and 2-line _sleep() helpers, differing only in provider-specific log event names.

Solution

New containers/api-proxy/oidc-refresh-utils.js exports:

  • scheduleRefresh(state, delayMs, refreshFn, providerPrefix) — shared scheduling with provider-specific log events
  • sleep(ms) — shared sleep helper

Both providers now delegate to the shared implementation through thin wrapper methods.

Verification

  • All 20 OIDC tests pass (12 AWS + 8 GCP)
  • Full api-proxy suite (627 tests) passes

Closes #2787

Extract duplicated _scheduleRefresh() and _sleep() methods from
AwsOidcTokenProvider and GcpOidcTokenProvider into shared
oidc-refresh-utils.js module.

The shared scheduleRefresh() function accepts a provider prefix
parameter to preserve provider-specific log event names
(aws_oidc_refresh_success vs gcp_oidc_refresh_success).

Both providers now delegate to the shared implementation while
keeping thin wrapper methods for backward compatibility.

Closes #2787

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 9, 2026 23:14
@lpcox lpcox requested a review from Mossaka as a code owner May 9, 2026 23:14
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 87.48% 87.55% 📈 +0.07%
Statements 87.44% 87.51% 📈 +0.07%
Functions 82.66% 82.66% ➡️ +0.00%
Branches 79.65% 79.69% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/container-lifecycle.ts 87.1% → 88.2% (+1.14%) 87.5% → 88.6% (+1.11%)

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

Copy link
Copy Markdown
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 PR refactors the api-proxy OIDC token providers by extracting duplicated refresh scheduling and sleep logic from the AWS and GCP OIDC providers into a shared utility module, while preserving provider-specific log event names.

Changes:

  • Added containers/api-proxy/oidc-refresh-utils.js with shared scheduleRefresh() and sleep() utilities.
  • Updated AwsOidcTokenProvider and GcpOidcTokenProvider to delegate _scheduleRefresh() and _sleep() to the shared utilities.
  • Kept provider-specific logging semantics via a providerPrefix parameter.
Show a summary per file
File Description
containers/api-proxy/oidc-refresh-utils.js Introduces shared refresh timer scheduling + sleep helper, including provider-prefixed logging.
containers/api-proxy/aws-oidc-token-provider.js Replaces inline refresh scheduling/sleep with shared utility calls.
containers/api-proxy/gcp-oidc-token-provider.js Replaces inline refresh scheduling/sleep with shared utility calls.

Copilot's findings

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Smoke Test Results ✅

Last 2 Merged PRs:

Tests:

  • ✅ GitHub MCP (PR listing)
  • ✅ Playwright (github.com title check)
  • ✅ File writing
  • ✅ Bash verification

Status: PASS

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

🔥 Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP (list PRs) ✅ PR #2800 returned successfully
GitHub.com connectivity ⚠️ Template var not substituted (pre-step skipped)
File write/read ⚠️ Template var not substituted (pre-step skipped)
BYOK inference (api-proxy → api.githubcopilot.com) ✅ Responding via BYOK offline mode

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com

PR author: @lpcox | Reviewers: @Mossaka, @Copilot

Overall: PARTIAL — BYOK inference ✅, pre-step outputs not injected (template vars unexpanded)

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions github-actions Bot mentioned this pull request May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

🔍 Smoke Test Results

Test Status
GitHub MCP connectivity ✅ Pass
GitHub.com HTTP connectivity ⚠️ N/A (pre-step data not injected)
File write/read ⚠️ N/A (pre-step data not injected)

PR: refactor: extract shared OIDC refresh/sleep utilities
Author: @lpcox | Reviewers: @Mossaka, @Copilot

Overall: ⚠️ PARTIAL — MCP test passed; pre-computed smoke data was not injected (template variables unsubstituted).

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Smoke Test: FAIL

  • ✅ GitHub PR review: refactor: remove dead re-exports from providers/index.js; fix(deps): patch high-severity vulnerabilities in babel and fast-uri
  • ❌ safeinputs-gh: unavailable
  • ✅ Playwright: title contains GitHub
  • ❌ Tavily: no tools exposed
  • ✅ File/bash: file verified
  • ✅ Discussion: commented on [Pelis Agent Factory Advisor] Pelis Agent Factory Advisor — 2026-05-02 Analysis #2411
  • ✅ Build: npm ci && npm run build
    Overall status: FAIL

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

github-actions Bot commented May 9, 2026

Chroot Smoke Test Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.14.1 v20.20.2
Go go1.22.12 go1.22.12

Overall: ❌ Not all versions match.

Go versions are aligned, but Python and Node.js differ between host and chroot. This may indicate the chroot environment is using system-installed runtimes (Ubuntu 22.04 defaults) rather than the host's newer versions.

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

🏗️ 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 issue #2811 · ● 586.1K ·

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING ❌ Timeout/no response
PostgreSQL pg_isready ❌ No response on port 5432
PostgreSQL SELECT 1 ❌ Timeout/no response

Overall: FAILhost.docker.internal services are not reachable from this environment. The agent container cannot connect to the host-side Redis or PostgreSQL service containers.

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox merged commit 6a1628a into main May 9, 2026
68 of 72 checks passed
@lpcox lpcox deleted the refactor/oidc-shared-refresh branch May 9, 2026 23:32
lpcox added a commit that referenced this pull request May 11, 2026
The OIDC refactoring PRs (#2811, #2772, #2887) added new JS modules
(github-oidc.js, aws-oidc-token-provider.js, gcp-oidc-token-provider.js,
oidc-refresh-utils.js) but did not update the Dockerfile COPY command.
This caused the api-proxy container to crash immediately on startup
with exit code 1 (Cannot find module './github-oidc'), breaking all
integration tests since commit 7c25298.

Fixes the api-proxy container startup crash that has been failing all
integration test runs on main since 2026-05-11T15:45Z.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lpcox added a commit that referenced this pull request May 11, 2026
… retry handling (#2895)

* Initial plan

* fix: reduce pid-tracker public API surface

* docs: fix stale pid tracker jsdoc

* fix: retry api-proxy startup when compose reports exited (1)

Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/fcf2b573-5256-4c69-8f65-0a79431bd838

* fix(api-proxy): add missing JS modules to Dockerfile COPY

The OIDC refactoring PRs (#2811, #2772, #2887) added new JS modules
(github-oidc.js, aws-oidc-token-provider.js, gcp-oidc-token-provider.js,
oidc-refresh-utils.js) but did not update the Dockerfile COPY command.
This caused the api-proxy container to crash immediately on startup
with exit code 1 (Cannot find module './github-oidc'), breaking all
integration tests since commit 7c25298.

Fixes the api-proxy container startup crash that has been failing all
integration test runs on main since 2026-05-11T15:45Z.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test: restore missing pid-tracker test cases for coverage

Add back tests for malformed /proc/net/tcp rows and non-symlink file
descriptors that were removed when the async trackPidForPort was dropped.
These paths are still exercised in production via trackPidForPortSync
and need coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Landon Cox <landon.cox@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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] _scheduleRefresh and _sleep methods duplicated between aws-oidc-token-provider.js and gcp-oidc-token-provider.js

2 participants