Skip to content

Conversation

Pouyanpi
Copy link
Collaborator

Update verbose logging to safely handle cases where log records may not have 'id' or 'task' attributes. Prevents potential AttributeError and improves robustness of LLM and prompt log output formatting.

@Pouyanpi Pouyanpi requested a review from Copilot August 19, 2025 09:46
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes potential AttributeError exceptions in verbose logging by adding safe attribute access for id and task fields in log records. The changes ensure the logging system gracefully handles cases where these attributes may be missing.

Key Changes

  • Replaces direct attribute access with getattr() calls using default values
  • Provides fallback display formatting when id is missing
  • Uses "unknown" as default for missing task attributes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Update verbose logging to safely handle cases where log records may not
have 'id' or 'task' attributes. Prevents potential AttributeError and
improves robustness of LLM and prompt log output formatting.
@Pouyanpi Pouyanpi force-pushed the fix/logging-verbose branch from 74fb99c to 3018311 Compare August 19, 2025 09:50
@Pouyanpi Pouyanpi self-assigned this Aug 19, 2025
@Pouyanpi
Copy link
Collaborator Author

required by #1339

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.71%. Comparing base (949e422) to head (3018311).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1343   +/-   ##
========================================
  Coverage    70.70%   70.71%           
========================================
  Files          161      161           
  Lines        16312    16317    +5     
========================================
+ Hits         11533    11538    +5     
  Misses        4779     4779           
Flag Coverage Δ
python 70.71% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
nemoguardrails/logging/verbose.py 90.90% <100.00%> (+0.39%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@erickgalinkin erickgalinkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Pouyanpi Pouyanpi added this to the v0.17.0 milestone Aug 28, 2025
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.

4 participants