Repository navigation
feat(errors): add error taxonomy and execute error contract - #139
Merged
Merged
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/v1.0.0.dev30 #139 +/- ##
========================================================
- Coverage 85.35% 84.80% -0.55%
========================================================
Files 706 720 +14
Lines 59459 61335 +1876
Branches 5917 6267 +350
========================================================
+ Hits 50750 52017 +1267
- Misses 6998 7465 +467
- Partials 1711 1853 +142
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.



Description
This PR introduces a semantic error taxonomy for model/backend errors and enforces a phase-specific error contract for
executeacross the core package and the nine backend extensions.Motivation: applications could previously only distinguish database failures by concrete class names (and often had to catch
DatabaseErrorand parse messages). Backend error translation was also inconsistent: some paths silently swallowed commit failures, some retried the wrong exception type, and framework errors were re-translated into driver errors.What changes:
DatabaseError:DataError,RecordError,PolicyError,ConcurrencyError,InfrastructureError. Existing classes are re-parented; names, constructors and raise sites are unchanged, andexcept DatabaseErrorkeeps working.retryable/transienthints;attach_diagnostics()attachesoperation,sqlstate,driver_code,backendandtransientwithout changing the message.execute/execute_manynow let frameworkDatabaseErrorsubclasses pass through unchanged, guarantee a raise when a backend handler forgets to raise, and surface auto-commit failures asTransactionError.TransactionError;CliNotFoundErrorremains the command-layer not-found error.execute_manyuses the shared mapping + auto-commit, and COPY client errors still roll back explicit transactions.Adds # (no issue)
Type of change
feat: A new featuredocs: Documentation only changes (if related to the new feature)test: Adding missing tests or correcting existing tests (for the new feature)perf: A code change that improves performance (if part of the feature)chore: Changes to the build process or auxiliary tools and libraries suchs as documentation generation (if related to the new feature)ci: Changes to our CI configuration files and scripts (if related to the new feature)build: Changes that affect the build system or external dependencies (if related to the new feature)revert: Reverts a previous commitBreaking Change
Impact on End-Users:
No backward-incompatible API changes are expected: existing exception classes keep their names and constructors, and every concrete error is still a
DatabaseError. Behavioural changes to note: a failed auto-commit now raisesTransactionErrorinstead of being logged and ignored; transient connection retries now actually run; and framework errors are no longer re-wrapped by backend handlers.Impact on Backend Developers (Custom Implementations):
No signature changes. A custom backend that implements
_handle_errorshould return to raising a taxonomy error; the core pipeline adds a defensiveDatabaseErrorfallback if the handler returns instead of raising. Backends may callattach_diagnosticsbut are not required to.Related Repositories/Packages
python-activerecord-testsuite(feature/error-taxonomy): taxonomy contract (feature/backend/errors/test_error_taxonomy.py).feature/error-taxonomy): driver classification, execute-phase contract tests, testsuite wrappers, and CI pinned to the core/testsuite feature branches:feature/error-taxonomyfor both core and testsuite, and will be restored to release branches after merge.Testing
Test Plan:
Local (shared venv, SQLite/offline):
CI (all green, core and testsuite pinned to
feature/error-taxonomy):Reproduction:
Checklist
README.md, etc.).changelog.d/<issue_number>.<type>.md).Additional Notes
changelog.d/<PR>.added.mdimmediately after the PR number exists (the checker requires the fragment number to equal the PR number).docs/exampleswere brought back in line with current APIs (DefaultTimestampMixin,DefaultOptimisticLockMixin, event handler signatures, async pool context getters, GraphQL loader/loop usage).ConnectionError/OperationalErrorare retried after reconnect; non-idempotent statements remain the caller's responsibility (documented in the execute docstring).feature/firebird-sync-onlybranch. This PR only aligns its sync execute phases and does not add forced async parity tests.test_pg19_copy_repack.py.