Skip to content

Refactor gateway entry normalization across Claude/Copilot/Gemini converters#42678

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/duplicate-code-gateway-config-transformation
Draft

Refactor gateway entry normalization across Claude/Copilot/Gemini converters#42678
Copilot wants to merge 2 commits into
mainfrom
copilot/duplicate-code-gateway-config-transformation

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Three gateway config converters in actions/setup/js independently implemented the same clone/mutate/URL-rewrite flow, creating drift risk for future schema or URL handling changes. This PR centralizes that transformation path while keeping provider-specific behavior isolated.

  • Shared normalization primitive

    • Added normalizeGatewayEntry(entry, urlPrefix, mutate?) in convert_gateway_config_shared.cjs.
    • Centralizes:
      • shallow clone of the entry
      • optional provider mutation
      • conditional URL rewrite (string URLs only)
  • Provider adapters reduced to intent-only mutations

    • convert_gateway_config_claude.cjs: sets type = "http" via mutation callback.
    • convert_gateway_config_copilot.cjs: ensures default tools = ["*"] when missing.
    • convert_gateway_config_gemini.cjs: removes type for transport auto-detection.
    • Removes duplicated per-file clone/rewrite blocks.
  • Coverage updates for shared path

    • Extended convert_gateway_config_adapters.test.cjs with a focused test for normalizeGatewayEntry, including immutability and URL rewrite behavior.
    • Existing adapter tests continue to validate provider-specific invariants.
function transformClaudeEntry(entry, urlPrefix) {
  return normalizeGatewayEntry(entry, urlPrefix, (transformed) => {
    transformed.type = "http";
  });
}
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor gateway config entry transformation to eliminate duplication Jul 1, 2026
Copilot AI requested a review from pelikhan July 1, 2026 07:06
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category refactor
Risk 🟡 medium
Priority medium
Score 40 / 100
Action 📦 batch_review

Score breakdown: impact 20 + urgency 8 + quality 12

Draft PR centralizing gateway config normalization across Claude/Copilot/Gemini converters. Good code-quality improvement with tests. Review alongside similar cross-provider refactors once ready.

Generated by 🔧 PR Triage Agent · 38 AIC · ⌖ 10.1 AIC · ⊞ 1.6K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment