fix(logging): add context to bare and generic error log messages#848
fix(logging): add context to bare and generic error log messages#848balgaly wants to merge 2 commits into
Conversation
Three log calls emitted no context or had generic messages that made debugging harder: - scan/util.py: include the failing git command in the exception log - auth/server.py: add descriptive prefix to bare LOG.exception(e) call - safety.py: include the unparseable version string and package spec in remediation version error messages Part of pyupio#577
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Friendly ping. happy to make any changes needed to get this across the line. The fix adds context to two categories of error log messages that were previously bare or too generic to be actionable in production. Let me know if there are style or scope concerns. 🙏 |
🚀 Artifacts — PR #848 by @balgaly (source: balgaly/safety)
Download the wheel file and binaries with gh CLI or from the workflow artifacts. 📦 Install & RunPre-requisites# Install uv if needed
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create and enter artifacts directory
mkdir artifacts && cd artifactsQuick Test with Python Packagebash -c 'set -euo pipefail; echo; echo "WARNING: You are about to download and execute CI artifacts from PR #848 by @balgaly (source: balgaly/safety). Do NOT proceed unless you have reviewed the PR diff and trust the source."; echo; read -rp "Type I understand to continue: " C; [ "$C" = "I understand" ] || { echo "Aborted."; exit 1; }; gh run download 24139254342 -n dist -R pyupio/safety; uvx safety-*-py3-none-any.whl --version'Run other Safety commands as followsuvx safety-*-py3-none-any.whl auth status
uvx safety-*-py3-none-any.whl auth login
uvx safety-*-py3-none-any.whl scan
|
self.git contains a Path element so str.join on self.git + cmd fails pyright's type check. Cast each element to str explicitly.
Summary
Addresses #577 by improving three error log calls that were either bare (no message) or generic (no context about what failed).
Changes
safety/scan/util.py__run__loggedLOG.exception(e)with no message when a git command failed. The log now includes the command string so it is clear which git invocation caused the error:safety/auth/server.pyThe authentication completion handler logged a bare
LOG.exception(e). Added a descriptive prefix so the log entry is self-explanatory:safety/safety.py(remediation version parsing)Three
LOG.errorcalls said only "Error getting X version, ignoring" with no indication of which package or what version string caused the failure. The messages now include the unparseable version string and the package spec:These are pure logging changes with no impact on runtime behaviour.