Skip to content

Fixed KeyError in _handle_rename by using correct args key#36063

Closed
Tim Ren (xr843) wants to merge 1 commit intolangchain-ai:masterfrom
xr843:fix/35852-handle-rename-keyerror
Closed

Fixed KeyError in _handle_rename by using correct args key#36063
Tim Ren (xr843) wants to merge 1 commit intolangchain-ai:masterfrom
xr843:fix/35852-handle-rename-keyerror

Conversation

@xr843
Copy link
Copy Markdown

Summary

Fixes #35852

  • The tool dispatch function in anthropic_tools.py builds the args dict with the source file path under key "path" (line 218 and 720), but both _handle_rename implementations (in _StateClaudeFileToolMiddleware and _FilesystemClaudeFileToolMiddleware) read args["old_path"], which is never set.
  • This causes a KeyError: 'old_path' whenever the rename command is invoked.
  • Fixed by changing args["old_path"] to args["path"] in both _handle_rename methods.

Test plan

  • Verify that the args dict is built with "path" as the key for the source path in both dispatch functions
  • Verify that "new_path" is correctly set when new_path is provided
  • Run rename operations through both _StateClaudeFileToolMiddleware and _FilesystemClaudeFileToolMiddleware to confirm no KeyError

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

The tool dispatch function builds the args dict with the source path
under key "path", but both _handle_rename implementations read
args["old_path"], which never exists. This causes a KeyError whenever
the rename command is used. Changed to args["path"] to match the
key set in the dispatch function.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added anthropic `langchain-anthropic` package issues & PRs integration PR made that is related to a provider partner package integration size: XS < 50 LOC labels Mar 18, 2026
@github-actions
Copy link
Copy Markdown

This PR has been automatically closed because you are not assigned to the linked issue.

External contributors must be assigned to an issue before opening a PR for it. Please:

  1. Comment on the linked issue to request assignment from a maintainer
  2. Once assigned, edit your PR description and the PR will be reopened automatically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

anthropic `langchain-anthropic` package issues & PRs external integration PR made that is related to a provider partner package integration missing-issue-link new-contributor size: XS < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_handle_rename in Claude file tool middleware raises KeyError on every rename command

1 participant