Skip to content

refactor: extract registrationErrors helper to deduplicate error-tracking in tool registration#7763

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

refactor: extract registrationErrors helper to deduplicate error-tracking in tool registration#7763
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-error-tracking

Conversation

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

registerAllToolsSequential and registerAllToolsParallel both contained the same 3-part pattern: declare failedServers []string, accumulate failures, call logRegistrationIncomplete. Any change to failure-tracking semantics had to be applied in two places.

Changes

  • New registrationErrors type — encapsulates failed []string + total int with record(serverID) and finish() methods; finish() owns the incomplete-registration log message
  • Removed logRegistrationIncomplete — its logic is now solely in registrationErrors.finish()
  • Refactored both registration functions to use errs.record() / errs.finish(); each still logs at its own level (LogError vs LogErrorToServer)
  • Removed redundant failureCount in the parallel path — replaced by len(errs.failed)
type registrationErrors struct {
    failed []string
    total  int
}

func (e *registrationErrors) record(serverID string) {
    e.failed = append(e.failed, serverID)
}

func (e *registrationErrors) finish() {
    if len(e.failed) > 0 {
        logger.LogError("backend", "Tool registration incomplete: %d of %d backends failed: %v — ...",
            len(e.failed), e.total, e.failed)
    }
}

GitHub Advanced Security started work on behalf of lpcox June 19, 2026 04:36 View session
GitHub Advanced Security finished work on behalf of lpcox June 19, 2026 04:38
GitHub Advanced Security started work on behalf of lpcox June 19, 2026 04:40 View session
Copilot AI changed the title [WIP] Refactor duplicate error tracking pattern in tool registration refactor: extract registrationErrors helper to deduplicate error-tracking in tool registration Jun 19, 2026
Copilot finished work on behalf of lpcox June 19, 2026 04:40
Copilot AI requested a review from lpcox June 19, 2026 04:40
GitHub Advanced Security finished work on behalf of lpcox June 19, 2026 04:41
@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 backend tool-registration failure tracking in the unified server by extracting shared “failed server accumulation + final summary log” logic into a dedicated helper type, reducing duplication between sequential and parallel registration paths.

Changes:

  • Introduced a registrationErrors helper type to centralize failure tracking (record) and final summary logging (finish).
  • Removed the now-redundant logRegistrationIncomplete helper function.
  • Simplified the parallel registration summary by deriving the failure count from len(errs.failed).
Show a summary per file
File Description
internal/server/tool_registry.go Deduplicates tool-registration error tracking/logging across sequential and parallel registration implementations.

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 561a21a into main Jun 19, 2026
40 checks passed
@lpcox lpcox deleted the copilot/duplicate-code-error-tracking 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