[19.0][IMP] endpoint_route_handler: restore _init_modules even when a test raises - #166
Merged
OCA-git-bot merged 1 commit intoSep 16, 2026
Conversation
Contributor
|
Hi @simahawk, |
Member
|
@AungKoKoLin1997 Please rebase. I guess it supplements #150 which was just merged. |
…raises 369de3f restores `registry._init_modules` after `_get_mocked_request`, but the restore happens after the `with MockRequest(...)` block without a `try/finally`. If the test body raises inside the mocked request, the exception propagates out of the generator and the restore line is never reached, so the process-wide registry is left with an empty module set again. That attribute is not rolled back with the test transaction, and `ir.http.routing_map()` builds the routing map from exactly that set: installed = registry._init_modules.union(config["server_wide_modules"]) so the next routing-map regeneration yields no module controllers at all and every later `HttpCase` in the same process gets a 404 for any route outside `base` - the very failure 369de3f set out to fix, just on the error path. Wrap the `yield` in `try/finally` so the restore always runs. Assisted-by: Claude Opus 5
AungKoKoLin1997
force-pushed
the
19.0-fix-endpoint_route_handler-init-modules
branch
from
September 16, 2026 07:48
c57237c to
6fc2084
Compare
AungKoKoLin1997
added a commit
to qrtl/ocj-oca
that referenced
this pull request
Sep 16, 2026
…ter a mocked request
`CommonEndpoint._get_mocked_request` empties `registry._init_modules` and never
puts it back. That attribute lives on the process-wide registry, so it is not
rolled back with the test transaction, and `ir.http.routing_map()` builds the
map from exactly that set:
installed = registry._init_modules.union(config['server_wide_modules'])
Once the endpoint tests have run, the next routing-map regeneration therefore
yields no module controllers at all, and every later `HttpCase` in the same
process gets a 404 for any route outside `base`. The endpoint suite itself
never noticed because nothing after it made an HTTP request.
Adding `queue_job` to this repository surfaced it: its post-install
`TestRunJobHttp` calls `/queue_job/runjob` and got 404 in CI while passing in
isolation. Restoring the previous value on exit fixes both those tests and
leaves the endpoint suite unchanged.
Upstream has since merged the same fix (OCA/web-api 369de3f), plus the pending
OCA/web-api#166 which moves the restore into a `try/finally` so it also runs
when a test raises inside the mocked request. This patch is that combined
state, so the next re-vendoring of the module is a no-op here.
Assisted-by: Claude Opus 5
yostashiro
pushed a commit
to qrtl/ocj-oca
that referenced
this pull request
Sep 16, 2026
…ter a mocked request (#43) `CommonEndpoint._get_mocked_request` empties `registry._init_modules` and never puts it back. That attribute lives on the process-wide registry, so it is not rolled back with the test transaction, and `ir.http.routing_map()` builds the map from exactly that set: installed = registry._init_modules.union(config['server_wide_modules']) Once the endpoint tests have run, the next routing-map regeneration therefore yields no module controllers at all, and every later `HttpCase` in the same process gets a 404 for any route outside `base`. The endpoint suite itself never noticed because nothing after it made an HTTP request. Adding `queue_job` to this repository surfaced it: its post-install `TestRunJobHttp` calls `/queue_job/runjob` and got 404 in CI while passing in isolation. Restoring the previous value on exit fixes both those tests and leaves the endpoint suite unchanged. Upstream has since merged the same fix (OCA/web-api 369de3f), plus the pending OCA/web-api#166 which moves the restore into a `try/finally` so it also runs when a test raises inside the mocked request. This patch is that combined state, so the next re-vendoring of the module is a no-op here. Assisted-by: Claude Opus 5
Contributor
|
/ocabot merge patch |
Contributor
|
What a great day to merge this nice PR. Let's do it! |
Contributor
|
Congratulations, your PR was merged at 6942a5e. Thanks a lot for contributing to OCA. ❤️ |
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.
Follow-up to 369de3f, which restores
registry._init_modulesafter_get_mocked_requestbut does the restore after thewith MockRequest(...)block, without atry/finally. If the test body raises inside the mocked request, the exception propagates out of the generator and the restore line is never reached, so the process-wide registry is left with an empty module set again.That attribute is not rolled back with the test transaction, and
ir.http.routing_map()builds the routing map from exactly that set:so the next routing-map regeneration yields no module controllers at all, and every later
HttpCasein the same process gets a 404 for any route outsidebase— the very failure 369de3f set out to fix, just on the error path.This PR wraps the
yieldintry/finallyso the restore always runs.🤖 Generated with Claude Code