Skip to content

fix: guard onError callback to prevent masking provider errors#218

Merged
mfeltscher merged 3 commits intofeat/provider-error-handlingfrom
copilot/sub-pr-217
Feb 16, 2026
Merged

fix: guard onError callback to prevent masking provider errors#218
mfeltscher merged 3 commits intofeat/provider-error-handlingfrom
copilot/sub-pr-217

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

The onError callback in AbstractErrorHandlingCacheTagsProvider was unguarded—if it threw, it would mask the original provider error and bypass throwOnError/fallback behavior.

Changes

  • Wrapped onError invocation in try-catch to isolate callback failures
  • Log callback exceptions separately via console.error without affecting error flow
  • Preserve deterministic behavior: original error is always thrown when throwOnError=true, fallback always returned when throwOnError=false
// Before: callback exception masks provider error
catch (error) {
  this.onError?.(error, { provider, method, args }); // throws → bypasses throwOnError
  if (this.throwOnError) throw error; // never reached
}

// After: callback exceptions isolated
catch (error) {
  try {
    this.onError?.(error, { provider, method, args });
  } catch (handlerError) {
    console.error(`Error handler itself failed in ${provider}.${method}.`, { handlerError });
  }
  if (this.throwOnError) throw error; // always executes correctly
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…rrors

Co-authored-by: mfeltscher <1352744+mfeltscher@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix configurable error handling for cache tags providers fix: guard onError callback to prevent masking provider errors Feb 16, 2026
Copilot AI requested a review from mfeltscher February 16, 2026 12:41
@mfeltscher mfeltscher marked this pull request as ready for review February 16, 2026 12:41
@mfeltscher mfeltscher merged commit bf0e7c8 into feat/provider-error-handling Feb 16, 2026
1 check passed
@mfeltscher mfeltscher deleted the copilot/sub-pr-217 branch February 16, 2026 12:42
mfeltscher added a commit that referenced this pull request Feb 16, 2026
* feat: make error handling of cache tags providers configurable

* fix: adjust default

* Apply suggestions from code review

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

* erroooooor

* errorrrrrs

* fix: guard onError callback to prevent masking provider errors (#218)

* Initial plan

* fix: wrap onError callback in try-catch to prevent masking original errors

Co-authored-by: mfeltscher <1352744+mfeltscher@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mfeltscher <1352744+mfeltscher@users.noreply.github.com>
Co-authored-by: Moreno Feltscher <moreno@smartive.ch>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mfeltscher <1352744+mfeltscher@users.noreply.github.com>
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.

2 participants