Skip to content

Log error when AttrR fails to validate value in update#330

Merged
GDYendell merged 1 commit intomainfrom
log-validate-error
Mar 3, 2026
Merged

Log error when AttrR fails to validate value in update#330
GDYendell merged 1 commit intomainfrom
log-validate-error

Conversation

@GDYendell
Copy link
Contributor

@GDYendell GDYendell commented Mar 2, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling for attribute value validation with improved logging to help identify validation failures.

@GDYendell GDYendell requested a review from shihab-dls March 2, 2026 14:21
@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

📝 Walkthrough

Walkthrough

The update method in the attribute reader class now wraps the datatype validation call with error handling, logging validation errors with context before re-raising the exception.

Changes

Cohort / File(s) Summary
Validation Error Handling
src/fastcs/attributes/attr_r.py
Added try/except ValueError block around datatype validation in the update method to log errors with value and attribute context before re-raising.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A validation check, so wise and true,
Now catches errors, logs them too,
Before the exception takes its flight,
We log the context, everything's right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding error logging when AttrR.update() fails to validate a value.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch log-validate-error

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

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

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.86%. Comparing base (dbb85c4) to head (05f0269).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #330      +/-   ##
==========================================
+ Coverage   90.85%   90.86%   +0.01%     
==========================================
  Files          70       70              
  Lines        2547     2551       +4     
==========================================
+ Hits         2314     2318       +4     
  Misses        233      233              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/fastcs/attributes/attr_r.py (1)

81-83: Include exception context in the validation-failure log.

Line 82 logs a plain error message but drops the caught exception details/traceback. Use exception-aware logging here (same pattern used at lines 100-104) so failures are diagnosable.

♻️ Proposed fix
-        except ValueError:
-            logger.error("Failed to validate value", value=repr(value), attribute=self)
+        except ValueError as e:
+            logger.opt(exception=e).error(
+                "Failed to validate value", value=repr(value), attribute=self
+            )
             raise
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fastcs/attributes/attr_r.py` around lines 81 - 83, The except ValueError
handler currently logs without exception context; update the handler in
attr_r.py to include the caught exception (use logger.exception(...) or
logger.error(..., exc_info=True)) so the traceback is recorded, preserving the
existing structured fields (value=repr(value), attribute=self) and then
re-raise; look for the ValueError except block associated with the validation
logic (the logger variable and self/attribute usage) and make it mirror the
exception-aware logging used at lines 100-104.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/fastcs/attributes/attr_r.py`:
- Around line 81-83: The except ValueError handler currently logs without
exception context; update the handler in attr_r.py to include the caught
exception (use logger.exception(...) or logger.error(..., exc_info=True)) so the
traceback is recorded, preserving the existing structured fields
(value=repr(value), attribute=self) and then re-raise; look for the ValueError
except block associated with the validation logic (the logger variable and
self/attribute usage) and make it mirror the exception-aware logging used at
lines 100-104.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbb85c4 and 05f0269.

📒 Files selected for processing (1)
  • src/fastcs/attributes/attr_r.py

@GDYendell GDYendell merged commit aff6341 into main Mar 3, 2026
11 checks passed
@GDYendell GDYendell deleted the log-validate-error branch March 3, 2026 15:05
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.

2 participants