Skip to content

[duplicate-code] Duplicate Code: Copilot SDK multi-provider parsing in driver sample and runtime entrypoint #43328

Description

@github-actions

🔍 Duplicate Code Detected: Copilot SDK multi-provider parsing

Analysis of commit 23337a0

Summary

The Copilot SDK sample driver reimplements the same multi-provider JSON validation and config shaping logic already present in the production driver. The overlap is large enough to create drift risk when the shape of GH_AW_COPILOT_SDK_MULTI_PROVIDER_JSON changes.

Duplication Details

Pattern: Multi-provider config parsing and validation

  • Severity: Medium
  • Occurrences: 2
  • Locations:
    • .github/drivers/copilot_sdk_driver_sample_node.cjs (lines 46-85)
    • actions/setup/js/copilot_sdk_driver.cjs (lines 48-85)
  • Code Sample:
function parseMultiProviderJson(value) {
  if (!value) return null;
  try {
    const parsed = JSON.parse(value);
    if (!parsed || typeof parsed !== "object") return null;
    if (!Array.isArray(parsed.providers) || parsed.providers.length < 1) return null;
    if (!Array.isArray(parsed.models) || parsed.models.length < 1) return null;
    if (!parsed.providers.every(isValidProviderConfig)) return null;
    if (!parsed.models.every(isValidModelConfig)) return null;
    return { model, providers: parsed.providers, models: parsed.models };
  } catch {
    return null;
  }
}

Impact Analysis

  • Maintainability: Any change to provider/model shape has to be updated in two places.
  • Bug Risk: One driver can accept a config the other rejects, or vice versa.
  • Code Bloat: The helper is repeated as near-identical boilerplate instead of being shared.

Refactoring Recommendations

  1. Extract the parser and shape validators into a shared helper module in actions/setup/js/.

    • Reuse it from both the production driver and the sample driver.
    • Keep the sample thin so its customization surface is still clear.
  2. If the sample must stay self-contained, at least import the validation helpers from the shared module and only keep the sample-specific wiring locally.

Implementation Checklist

  • Review duplication findings
  • Prioritize refactoring tasks
  • Create refactoring plan
  • Implement changes
  • Update tests
  • Verify no functionality broken

Analysis Metadata

  • Analyzed Files: 4
  • Detection Method: Serena semantic code analysis
  • Commit: 23337a0
  • Analysis Date: 2026-07-04

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by 🔍 Duplicate Code Detector · 11.7 AIC · ⌖ 6.07 AIC · ⊞ 13.3K ·

  • expires on Jul 5, 2026, 10:27 PM UTC-08:00

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions