chore: fix model attribute accessor#11976
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR updates two core modules: the logging handler to properly preserve exception information in structured logs by computing messages once and passing enriched exception context through kwargs, and the cross-module schema checking to retrieve model fields from the class type rather than the instance. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning, 1 inconclusive)
✅ Passed checks (4 passed)
✨ 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 |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #11976 +/- ##
==========================================
- Coverage 37.44% 37.43% -0.02%
==========================================
Files 1616 1616
Lines 79060 79060
Branches 11946 11946
==========================================
- Hits 29607 29598 -9
- Misses 47795 47804 +9
Partials 1658 1658
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lfx/src/lfx/schema/cross_module.py (1)
48-57:⚠️ Potential issue | 🟠 MajorAlign the guard to class-level access; check the class instead of the instance.
Line 48 checks
hasattr(instance, "model_fields"), but line 57 accessestype(instance).model_fields. This inconsistency creates a robustness gap: the guard doesn't match the actual access pattern, and in edge cases could leave an unguarded class-level access. Use the class-level check to ensure consistency.Proposed fix
- if not hasattr(instance, "model_fields"): + instance_type = type(instance) + if not hasattr(instance_type, "model_fields"): return False @@ - instance_fields = set(type(instance).model_fields.keys()) + instance_fields = set(instance_type.model_fields.keys())🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lfx/src/lfx/schema/cross_module.py` around lines 48 - 57, The guard currently checks hasattr(instance, "model_fields") but the code later accesses type(instance).model_fields, so update the guard to perform a class-level check (e.g., use hasattr(type(instance), "model_fields")) to match the subsequent access; ensure the code that computes instance_fields uses the same class-level attribute access (type(instance).model_fields) and keep the existing cls/model_fields check for cls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/lfx/src/lfx/schema/cross_module.py`:
- Around line 48-57: The guard currently checks hasattr(instance,
"model_fields") but the code later accesses type(instance).model_fields, so
update the guard to perform a class-level check (e.g., use
hasattr(type(instance), "model_fields")) to match the subsequent access; ensure
the code that computes instance_fields uses the same class-level attribute
access (type(instance).model_fields) and keep the existing cls/model_fields
check for cls.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
src/frontend/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
src/lfx/src/lfx/log/logger.pysrc/lfx/src/lfx/schema/cross_module.py
* log errors in production even with dev; surpress model attribute warnings * revert logger changes
Fixes accessor on model: