Skip to content

Empty catch blocks silently swallow exceptions in async flows #398

@rido-min

Description

@rido-min

Summary

Several async code paths use empty catch { } blocks that silently swallow exceptions, making failures invisible and debugging difficult.

Locations

File Line Context
Teams.Apps/App.cs 302-303 Token retrieval failure silently ignored
Teams.Apps/Contexts/Context.SignIn.cs 71 OAuth token exchange failure silently ignored
Plugins.External.McpClient/McpClientPlugin.cs 137-145 All exceptions from Task.WhenAll swallowed (comment says handled later, but pattern is fragile)

Impact

  • Authentication/token failures become invisible — users see downstream errors with no root cause
  • OAuth flow failures are masked — sign-in silently fails without any indication of why
  • MCP tool fetching errors could be lost if the downstream handling has bugs

Suggested fix

At minimum, log the exception before suppressing it. Where the exception represents a recoverable condition, catch the specific exception type rather than using a bare catch. Where the intent is "try but don't fail", use a pattern like:

catch (Exception ex) when (LogAndSuppress(ex))
{
}

or simply:

catch (Exception ex)
{
    _logger.Warning("Token retrieval failed, proceeding without token", ex);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions