fix(approval,mcp): log silent exception handlers, narrow OAuth catches, close server on error - #6924
Closed
aaronlab wants to merge 1 commit into
Closed
Conversation
…s, close server on error Three silent `except Exception` blocks in approval.py (lines 345, 387, 469) return fallback values with zero logging — making it impossible to debug callback failures, allowlist load errors, or config read issues. Add logger.warning/error calls that match the pattern already used by save_permanent_allowlist() and _smart_approve() in the same file. In mcp_oauth.py, narrow the overly-broad `except Exception` in get_tokens() and get_client_info() to the specific exceptions Pydantic's model_validate() can raise (ValueError, TypeError, KeyError), and include the exception message in the warning. Also wrap the _wait_for_callback() polling loop in try/finally so the HTTPServer is always closed — previously an asyncio.CancelledError or any exception in the loop would leak the server socket. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Merged via PR #7094. Your commit was cherry-picked onto current main with your authorship preserved in git log. All three fixes (approval logging, narrowed OAuth catches, server_close in finally) address real issues. Thanks! |
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
approval.py: Three
except Exceptionblocks (lines 345, 387, 469) silently return fallback values (set(),"deny",{}) with zero logging — making callback failures, allowlist load errors, and config read issues impossible to diagnose. Addedlogger.warning/logger.errorcalls consistent with the existing pattern used bysave_permanent_allowlist()(line 357) and_smart_approve()(line 535) in the same file.mcp_oauth.py – get_tokens() / get_client_info(): Narrowed overly-broad
except Exceptionto(ValueError, TypeError, KeyError)— the specific exceptions Pydantic'smodel_validate()raises for corrupt data. The broad catch previously swallowed unexpected errors (e.g.MemoryError, filesystem bugs) that should propagate. Also added the exception message to the warning log.mcp_oauth.py – _wait_for_callback(): Wrapped the polling loop in
try/finallysoserver.server_close()is always called. Previously, anasyncio.CancelledErroror any exception duringawait asyncio.sleep()would skip the close and leak the HTTPServer socket.Test plan
🤖 Generated with Claude Code