New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-33600: Improve error handling in registry query methods #651
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
My only quibble is with one of the exception additions: at least most (maybe all) of the direct raises of CollectionError
(as opposed to one of its derived classes) seem like they might be better remaining as TypeError
, or maybe a new exception like NoDefaultProvided
that inherits from it - they're cases where an argument isn't being provided to a method, and no default was provided at Registry
initialization. To me that's on the spectrum of function-signature-mismatch logic bugs (which are reliably TypeError
in Python), and the kind of thing that a more strongly-typed implementation might even statically reject (e.g. if RegistryWithDefaults
was not the same class as RegistryWithoutDefaults
), and not terribly related to the CollectionError
subclasses.
I think I'll add I also realized that I probably need to expose some exception classes at the |
Handling of binds in InspectionVisitor was incomplete which caused issues with checking for governor constraints. This patch handles bind values as literals which fixes the issue. A simple unit test is added to reproduce the issue.
Check that literal values given for governor dimensions in WHERE expressions are actually know, raise a LookupError if values are not known.
Also changed annotated return type of Registry query methods to return query result instances instead of iterables. Added docstrings for raised exception to query methods.
This introduces exception class hierarchy for use in registry methods. It is limited to registry only and does not touch core module or datastore, though some changes in Butler class were needed to make it consistent with registry exceptions. Registry docstrings were updated to enumerate expected exception types. There is still no guarantee that raised exceptions will be limited to classes in this hierarchy, there is always a possibility that exceptions from other modules will leak. In particular there was no attempt in this commit to convert possible SQLAlchemy exceptions into registry-specific types.
6941eb3
to
59ef99b
Compare
Codecov Report
@@ Coverage Diff @@
## main #651 +/- ##
==========================================
+ Coverage 83.60% 83.65% +0.05%
==========================================
Files 239 239
Lines 30254 30367 +113
Branches 5066 5086 +20
==========================================
+ Hits 25295 25405 +110
- Misses 3806 3809 +3
Partials 1153 1153
Continue to review full report at Codecov.
|
@TallJimbo, could you check 12540ac, I have added a small paragraph documenting exceptions and explain_no_results? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made added some patch recommendations with newlines between sentences and very small grammatical fixes.
aade7fb
to
e6d6b07
Compare
Several related changes, some small and some big:
explain_no_result
to the result class returned fromqueryDimensionRecords
.Checklist
doc/changes