fix(spp_hide_menus_base): make the menu-hiding pass best-effort on database errors (#526) - #532
Open
gonzalesedwin1123 wants to merge 3 commits into
Open
gonzalesedwin1123 wants to merge 3 commits into
gonzalesedwin1123 wants to merge 3 commits into
Conversation
…tabase errors hide_menus() runs from ir.module.module._register_hook at the end of every registry load. A psycopg2.Error escaping it aborted the registry load, so on a poisoned cursor every restart failed until the database was repaired by hand. The pass now flushes the caller's pending writes, runs in its own savepoint, and logs and skips any psycopg2.Error; a missing menu xmlid uses raise_if_not_found=False. Fixes #526
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 19.0 #532 +/- ##
==========================================
+ Coverage 76.91% 77.05% +0.14%
==========================================
Files 704 727 +23
Lines 45774 47171 +1397
==========================================
+ Hits 35205 36346 +1141
- Misses 10569 10825 +256
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
- test_02 gains a control run proving the catalog entry hides the menu before the failing pass, so the rollback assertions are falsifiable - warning assertion matches the message text, not the logger name - HISTORY attributes the incident to odoo-job-worker#22, which #383 had first pinned on the menu-icon hook - docstring states why only psycopg2.Error is caught, why the pass is all-or-nothing, and that retryable errors are swallowed on purpose - log line no longer claims the registry load continues on an already aborted transaction - flatten the extracted loop; explicit psycopg2.errors import
gonzalesedwin1123
marked this pull request as ready for review
September 21, 2026 03:24
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.
Fixes #526. Sibling of #525 (#383), scoped to the hook that actually runs on the registry-load path.
Problem
spp_hide_menus_baserunshide_menus()fromir.module.module._register_hook, i.e. at the end of every registry load (startup, install, upgrade, every worker reload). Inside it callssearch,env.ref→_xmlid_lookup, andspp.hide.menucreate/write, with only aValueErrorguard around the lookup. Anypsycopg2.Errorpropagated out of_register_hookand aborted the registry load. On a cursor already poisoned by an unrelated failure that meant every restart died withInFailedSqlTransactionuntil the database was quarantined — the shape of the 2026-07-30 preprod incident (odoo-job-worker#22).Fix
hide_menus()is now the guarded entry point used by bothnext()and_register_hook():cr.flush()first, so the caller's own pending writes stay the caller's error (the fix(spp_base_common): make the menu-icon hook best-effort on database errors #525 review finding);with cr.savepoint():and anypsycopg2.Erroris logged at WARNING withexc_info=Trueand skipped. Hiding a menu is best-effort at registry load: a menu left visible is recoverable, an aborted registry load is an outage (spp.hide.menu: a duplicate menu_id row aborts the registry load (ValueError: Expected singleton in _register_hook) #408);_hide_catalog_menus();env.ref(..., raise_if_not_found=False)replaces theexcept ValueError.spp_hide_menus_base19.0.2.1.0 → 19.0.2.1.1 with a HISTORY fragment. README/index.html left for CI's pinned generator.Tests (
tests/test_register_hook_guard.py, 4 new)_register_hook(): returns, warns, transaction still usable, and the pass is atomic (a menu hidden earlier in the same pass is rolled back); order-independent via the first/last rows ofir.module.module.search([]);_register_hook(): no raise, warning logged;hide_menus()raisesInFailedSqlTransactionand logs nothing (the guard does not swallow it).Pre-fix: tests 2 and 3 error with
UndefinedTable/InFailedSqlTransactionout of_register_hook. Post-fix:0 failed, 0 error(s) of 29 tests. All pre-commit hooks pass on the changed files.Out of scope: #410 (re-snapshot in
hide_menu()), same path, separate issue.