Skip to content

[19.0)[Fix]endpoint_route_handler: Restore registry._init_modules after mocked request - #150

Open
Camille0907 wants to merge 1 commit into
OCA:19.0from
Camille0907:19.0-fix-endpoint_route_handler
Open

[19.0)[Fix]endpoint_route_handler: Restore registry._init_modules after mocked request#150
Camille0907 wants to merge 1 commit into
OCA:19.0from
Camille0907:19.0-fix-endpoint_route_handler

Conversation

@Camille0907

Copy link
Copy Markdown

_get_mocked_request() sets registry._init_modules = set() to simulate a minimal endpoint environment. Since registry is the real Odoo Registry singleton, this mutation persisted after the context exited.

Odoo core ir_http.py uses registry._init_modules to build the routing map, so leaving it as set() caused post_install HttpCase tests from other modules to receive a routing map containing only server-wide modules, resulting in 404 errors on routes registered by those modules.

Fix by saving and restoring _init_modules in a try/finally block.

…fter mocked request

`_get_mocked_request()` sets `registry._init_modules = set()` to simulate a minimal endpoint environment.
Since registry is the real Odoo Registry singleton, this mutation persisted after the context exited.

Odoo core `ir_http.py` uses `registry._init_modules` to build the routing map, so leaving it as set() caused post_install HttpCase tests from other modules to receive a routing map containing only server-wide modules, resulting in 404 errors on routes registered by those modules.

Fix by saving and restoring _init_modules in a try/finally block.
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @simahawk,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:19.0 mod:endpoint_route_handler Module endpoint_route_handler labels Aug 17, 2026

@simahawk simahawk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your fix.
Please, amend the commit msg to remove the odoo version and use the tag [FIX]

yield mocked_request
registry = (env or self.env).registry
original_init_modules = registry._init_modules
try:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO there's no need for a try/finally.
This is ctx manager, you can cleanup what you want after the yield statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:endpoint_route_handler Module endpoint_route_handler series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants