Fix exception handling and validator anti-patterns#92
Merged
Miyamura80 merged 1 commit intomainfrom Jan 27, 2026
Merged
Conversation
- Replace broad Exception catches with specific exception types - Fix unsafe exception re-instantiation in logging_config.py - Replace validator anti-pattern with default_factory in global_config.py - Remove setup_logging() call at import time in flags.py to avoid circular imports https://claude.ai/code/session_01NXo5yv7Qpp2HxBe6APW1Go
Contributor
Greptile OverviewGreptile SummaryThis PR systematically addresses five high-priority code quality issues by removing overly broad exception handling, fixing Pydantic validator anti-patterns, and eliminating a circular import risk. Key improvements:
Confidence Score: 5/5
Important Files Changed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses five high-priority code quality issues: removes overly broad exception handling, fixes Pydantic validator anti-patterns, eliminates circular import risk, and improves exception re-instantiation safety.
Changes
common/flags.py: Deletedsetup_logging()call at import time to prevent circular dependency issuescommon/global_config.py: Replaced@field_validatordecorators that ignored input parametervwithdefault_factorylambdas foris_localandrunning_onfieldssrc/utils/logging_config.py: Changed broadExceptioncatch to specificTypeErrorwhen re-instantiating exceptions; improved fallback message formattingutils/llm/dspy_langfuse.py:Exceptionto(ValueError, KeyError, TypeError)for cost calculation errorsExceptionto(TypeError, ValueError, ZeroDivisionError, AttributeError)for token calculation errorsExceptionto(TypeError, AttributeError, RecursionError)for output serialization errorsTesting
make test)make ci)Related Issues
Closes #