Skip to content

fix: replace catch (e: any) with proper unknown handling in mcp/index.ts - #24503

Closed
alfredocristofano wants to merge 2 commits into
anomalyco:devfrom
alfredocristofano:contrib/cristofano-mcp
Closed

alfredocristofano wants to merge 2 commits into
anomalyco:devfrom
alfredocristofano:contrib/cristofano-mcp

Conversation

@alfredocristofano

@alfredocristofano alfredocristofano commented Apr 26, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #24327

Type of change

  • Refactor / code improvement

What does this PR do?

Replaces two instances of catch: (e: any) with proper unknown error handling in src/mcp/index.ts.

  • fetchFromClient (line 169): e: any → e with e instanceof Error guard
  • withClient (line 692): e: any → e with e instanceof Error guard

The project style guide explicitly prohibits any ("Avoid any; prefer precise types"). The e: any annotation disables type checking and can cause runtime crashes if the caught value is not an Error (e.g. null, undefined, or a plain string). Both sites accessed .message directly, which would throw at runtime for non-Error values.

How did you verify your code works?

  • The fix uses e instanceof Error ? e.message : String(e) for safe message extraction
  • Returns e instanceof Error ? e : new Error(String(e)) to preserve the Error contract expected by Effect.tryPromise
  • No behavioral changes — only type safety improvements

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I have read the CONTRIBUTING.md guidelines

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@alfredocristofano

Copy link
Copy Markdown
Author

Closing this one myself. The branch picked up a large unrelated diff and now shows conflicts, so it is not useful for review in its current form. I’ll keep the issue open for a cleaner fix.

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.

[BUG] ~30 catch blocks silently swallow errors across core modules

1 participant