fix: improve error handling in get_blocklisted_functions#1029
Conversation
- Handle HTTP status codes explicitly instead of using raise_for_status() - Only report 500+ errors to Sentry (actual server issues) - Treat 401/404 as expected cases (not authorized, PR not found) - Handle 200 responses with error key gracefully - Add debug logging for better observability Fixes PYTHON-CLI-2T5
| elif not req.ok: | ||
| logger.warning(f"Unexpected response {req.status_code} from verify-existing-optimizations") | ||
|
|
||
| if not req.ok: |
There was a problem hiding this comment.
repeat of previous condition
Co-authored-by: Aseem Saxena <aseem.bits@gmail.com>
|
@claude review this |
|
Claude finished @aseembits93's task in 1m 7s —— View job Code Review Complete
SummaryGood improvement to reduce Sentry noise! The changes properly distinguish between expected client errors (401/404) and actual server errors (500+). However, there are several issues that need to be addressed: Issues Found1. Critical: Type Error on Line 364 🔴Location: if "error" in content.lower():Problem: Impact: This will cause the function to crash and fall through to the exception handler, defeating the purpose of the improved error handling. Fix: You likely meant to check if "error" is a key in the dictionary: if "error" in content:Or if you want to check the string representation: if "error" in str(content).lower():2. Logic Issue: Duplicate Condition on Line 359
|
Summary
get_blocklisted_functions()that was causing excessive Sentry alertsContext
Issue PYTHON-CLI-2T5 has 10,769 occurrences since April 2025. The endpoint works correctly, but the CLI was treating all non-2xx responses as exceptions worth reporting.