Repository navigation
fix(tools): introduce ToolInputError to classify expected tool failures - #383
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
sentry-junior
Bot
force-pushed
the
jr/fix-editfile-enoent-handling
branch
from
May 20, 2026 18:42
be7ecdb to
30f21be
Compare
The tool error handler sent all non-MCP tool errors to Sentry via logException, even when the error was caused by invalid model input (missing files, bad regex, ambiguous edits, path traversal). This created noisy alerts for expected conditions. Introduce ToolInputError — a semantic error class for model/user-caused tool failures. The global tool error handler now skips logException for both McpToolError and ToolInputError, logging warnings instead. Domain code throws ToolInputError at source where it knows the failure is expected input, not a system error: - edit-file: missing file (ENOENT) - text-edits: all validation (not found, ambiguous, overlap, no-op) - file-utils: workspace path traversal - list-dir: not-a-directory - grep: invalid regex pattern - sandbox executor: missing required arguments System errors (sandbox API failures, Slack errors, network issues) still propagate as normal Errors and report to Sentry. Fixes JUNIOR-2Q Co-Authored-By: Claude (anthropic/claude-opus-4.6) <[email protected]>
sentry-junior
Bot
force-pushed
the
jr/fix-editfile-enoent-handling
branch
from
May 20, 2026 18:47
30f21be to
76a235f
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The tool error handler (
handleToolExecutionError) sent all non-MCP tool errors to Sentry vialogException, even when the error was caused by invalid model input — missing files, bad regex, ambiguous edits, path traversal. This created noisy alerts for expected conditions like JUNIOR-2Q.This introduces
ToolInputErroras the single classification mechanism for expected model/user-caused tool failures. Domain code throwsToolInputErrorat the source where it knows the failure is input-caused, not a system error. The global error handler respects this: nologException, no Sentry noise.Architecture
No ad-hoc error-type catches at the executor level. The domain function that creates the error owns the classification.
Changes
New:
tool-input-error.ts—ToolInputErrorclassError handler:
tool-error-handler.ts— skiplogExceptionforToolInputError; replacegetMcpAwareErrorTypewithgetToolErrorType()covering both MCP and input error classificationDomain sources that now throw
ToolInputError:edit-file.ts— ENOENT onfs.readFile→ToolInputError("File not found: ...")text-edits.ts— all validation (not found, ambiguous, overlap, no-op, empty oldText, bad newText)file-utils.ts— workspace path traversallist-dir.ts— not-a-directorygrep.ts— invalid regex patternsandbox.ts— missing required arguments (path, edits, pattern, command)What stays as system errors (still reports to Sentry):
throwSandboxOperationError)unsupported sandbox tool(config error)Tests
tool-error-handler.test.ts(new) — system errors calllogException;ToolInputErrorandMcpToolErrordo notfile-tools.test.ts—ToolInputErrorfor ambiguous edits, text not found, path traversal, invalid regex, file-as-directorysandbox-executor.test.ts— editFile on missing path throwsToolInputErrorVerification
pnpm typecheck✅Fixes JUNIOR-2Q
Requested-By: David Cramer