Skip to content

refactor(config): extract applyCommonServerConfigFields to eliminate stdio/HTTP duplication#7764

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-serverconfig-initialization
Jun 19, 2026
Merged

refactor(config): extract applyCommonServerConfigFields to eliminate stdio/HTTP duplication#7764
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-serverconfig-initialization

Conversation

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Both the HTTP and stdio paths in config_stdin.go were setting the same 5 ServerConfig fields (Tools, ToolResponseFilters, Registry, GuardPolicies, Guard) plus an identical ToolTimeout nil-check — any new shared field required updating two places, with silent divergence risk (already happened with ConnectTimeout).

Changes

  • New helper applyCommonServerConfigFields(cfg *ServerConfig, src *StdinServerConfig) — sets all shared fields in one place
  • HTTP path (convertStdinServerConfig): removes inline field assignments, calls helper; ConnectTimeout remains HTTP-only
  • stdio path (buildStdioServerConfig): removes inline field assignments and ToolTimeout nil-check, calls helper
func applyCommonServerConfigFields(cfg *ServerConfig, src *StdinServerConfig) {
    cfg.Tools = src.Tools
    cfg.ToolResponseFilters = src.ToolResponseFilters
    cfg.Registry = src.Registry
    cfg.GuardPolicies = src.GuardPolicies
    cfg.Guard = src.Guard
    if src.ToolTimeout != nil {
        cfg.ToolTimeout = *src.ToolTimeout
    }
}

Copilot AI changed the title [WIP] Refactor duplicate server config field initialization in config_stdin.go refactor(config): extract applyCommonServerConfigFields to eliminate stdio/HTTP duplication Jun 19, 2026
Copilot finished work on behalf of lpcox June 19, 2026 04:35
Copilot AI requested a review from lpcox June 19, 2026 04:35
GitHub Advanced Security started work on behalf of lpcox June 19, 2026 04:38 View session
GitHub Advanced Security finished work on behalf of lpcox June 19, 2026 04:39
GitHub Advanced Security started work on behalf of lpcox June 19, 2026 04:41 View session
GitHub Advanced Security finished work on behalf of lpcox June 19, 2026 04:42
@lpcox lpcox marked this pull request as ready for review June 19, 2026 13:48
Copilot AI review requested due to automatic review settings June 19, 2026 13:48

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 refactors stdin JSON server config conversion to reduce duplication between HTTP and stdio server handling by extracting shared ServerConfig field assignments into a single helper.

Changes:

  • Introduces applyCommonServerConfigFields(cfg *ServerConfig, src *StdinServerConfig) to apply shared fields (Tools, ToolResponseFilters, Registry, GuardPolicies, Guard, and ToolTimeout when present).
  • Updates the HTTP conversion path to use the helper while keeping ConnectTimeout HTTP-specific.
  • Updates the stdio conversion path to use the helper and removes duplicated inline assignments / ToolTimeout nil-check.
Show a summary per file
File Description
internal/config/config_stdin.go Extracts common stdin→ServerConfig field application into a helper and uses it in both HTTP and stdio conversion paths to prevent drift.

Copilot's findings

Tip

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

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

@lpcox lpcox merged commit cba9e0c into main Jun 19, 2026
41 checks passed
@lpcox lpcox deleted the copilot/duplicate-code-serverconfig-initialization branch June 19, 2026 14:35
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