Skip to content

🧹 Refactor error handling in debug_log to log OSErrors instead of silently passing#11

Closed
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
jules-12771404410622688068-b074a076
Closed

🧹 Refactor error handling in debug_log to log OSErrors instead of silently passing#11
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
jules-12771404410622688068-b074a076

Conversation

@google-labs-jules
Copy link
Copy Markdown

🎯 What: Modified hooks/security_guard.py and hooks/secret_scanner.py's debug_log functions. Replaced except Exception: pass with except OSError as e: and added a print statement.
πŸ’‘ Why: Silently catching Exception hides unrelated errors (NameError, TypeError) and masking IOError failures makes logging issues difficult to debug.
βœ… Verification: Ran pytest tests directly and manually checked that python -m py_compile works, plus completed code review ensuring sys.stderr was safe. Made sure __pycache__ artifacts are removed.
✨ Result: Improved maintainability, debuggability, and consistency across codebase hook scripts.


PR created automatically by Jules for task 12771404410622688068 started by @zknpr

Narrow exception block to catch `OSError` instead of general `Exception`, and add print statement to `sys.stderr` when failed to write log. This change is to avoid silently suppressing actual programming bugs and provides visibility into IOError/PermissionError logging failures without crashing the application.
@google-labs-jules
Copy link
Copy Markdown
Author

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@zknpr
Copy link
Copy Markdown
Owner

zknpr commented May 25, 2026

Closing in favor of #17, which consolidates all 16 open hook PRs into one coherent change (they overlapped and conflicted with each other, so they could not be merged independently). Closing without merging: narrowing debug_log from except Exception to OSError plus printing to stderr makes a best-effort logger less crash-safe and noisier inside a hook. #17 keeps the logger crash-safe; the genuine fix was for state saves (see #4), which #17 includes.

@zknpr zknpr closed this May 25, 2026
@google-labs-jules
Copy link
Copy Markdown
Author

Closing in favor of #17, which consolidates all 16 open hook PRs into one coherent change (they overlapped and conflicted with each other, so they could not be merged independently). Closing without merging: narrowing debug_log from except Exception to OSError plus printing to stderr makes a best-effort logger less crash-safe and noisier inside a hook. #17 keeps the logger crash-safe; the genuine fix was for state saves (see #4), which #17 includes.

Understood. Acknowledging that this work is now obsolete as it has been superseded by #17, and stopping work on this task.

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