Skip to content

Replace bare except: with except Exception: in macOS handlers#1434

Open
hobostay wants to merge 1 commit into
trycua:mainfrom
hobostay:fix/bare-except-macos-handlers
Open

Replace bare except: with except Exception: in macOS handlers#1434
hobostay wants to merge 1 commit into
trycua:mainfrom
hobostay:fix/bare-except-macos-handlers

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 4, 2026

Summary

  • Replace 5 bare except: clauses in computer-server/computer_server/handlers/macos.py with except Exception:
  • Bare except: catches SystemExit, KeyboardInterrupt, and GeneratorExit, preventing clean process shutdown during accessibility tree traversal
  • except Exception: still catches all runtime errors while allowing interrupt signals to propagate correctly

Affected methods:

  • get_application_windows() (line 825)
  • get_all_windows() inner loop (line 859) and outer (line 863)
  • click_and_drag() cleanup (line 1195)
  • drag() cleanup (line 1232)

Test plan

  • Verify macOS accessibility handlers still gracefully handle AX API errors
  • Verify Ctrl+C can now cleanly interrupt the process during accessibility tree traversal

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Enhanced error handling in macOS system operations by refining exception-catching behavior across application window and drag interaction methods.

Bare except: clauses catch all exceptions including SystemExit,
KeyboardInterrupt, and GeneratorExit, preventing clean process
shutdown during accessibility tree traversal. Replace with
except Exception: to only catch actual errors while allowing
interrupt signals to propagate correctly.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 4, 2026

Someone is attempting to deploy a commit to the Cua Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c91bd254-cbb8-42c4-9d15-c8bd1fe26fb8

📥 Commits

Reviewing files that changed from the base of the PR and between e5098af and 79bd558.

📒 Files selected for processing (1)
  • libs/python/computer-server/computer_server/handlers/macos.py

📝 Walkthrough

Walkthrough

The PR updates bare except: clauses to except Exception: in the macOS handler methods get_application_windows, get_all_windows, drag_to, and drag. This narrows exception-catching scope to exclude system-exiting exceptions while preserving existing fallback behaviors.

Changes

Exception Handling Specificity

Layer / File(s) Summary
Exception Clause Narrowing
libs/python/computer-server/computer_server/handlers/macos.py
Four methods updated: get_application_windows (line 822-827), get_all_windows inner and outer handlers (859-865), drag_to cleanup handler (1192-1198), and drag cleanup handler (1229-1235) all replace bare except: with except Exception: to avoid catching system-exiting exceptions while keeping fallback behavior intact.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops through code so fine,
Bare excepts? Not in this line!
Exception-specific, clean and neat,
System exits now can safely beat! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: replacing bare except clauses with except Exception in macOS handlers, matching the primary objective of the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 4/8 reviews remaining, refill in 24 minutes and 21 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant