security(spp_api_v2_simulation): fix stale router import that breaks the API V2 app#358
Draft
gonzalesedwin1123 wants to merge 4 commits into
Draft
security(spp_api_v2_simulation): fix stale router import that breaks the API V2 app#358gonzalesedwin1123 wants to merge 4 commits into
gonzalesedwin1123 wants to merge 4 commits into
Conversation
…ale router import Call _get_fastapi_routers() on the api_v2 fastapi.endpoint and assert the /aggregation router is included. Fails before the fix with ModuleNotFoundError (routers.aggregation was renamed to routers.analytics). No existing test built the app, so the stale import went uncaught.
…nalytics router routers/aggregation.py was renamed to routers/analytics.py (which still exports aggregation_router), but fastapi_endpoint._get_fastapi_routers() still imported from ..routers.aggregation. That import runs during FastAPI app construction, which the dispatcher performs for a request to the API root before endpoint-level OAuth/JWT checks, so an unauthenticated request raised ModuleNotFoundError and took the whole API V2 endpoint down. Import from ..routers.analytics instead.
…import fix 19.0.2.0.0 -> 19.0.2.0.1. README.rst / index.html to be regenerated from CI.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 19.0 #358 +/- ##
==========================================
- Coverage 74.28% 68.25% -6.04%
==========================================
Files 372 113 -259
Lines 25385 9305 -16080
==========================================
- Hits 18857 6351 -12506
+ Misses 6528 2954 -3574
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Applied verbatim from CI's pinned oca-gen-addon-readme output.
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.
Problem
spp_api_v2_simulation/routers/aggregation.pywas renamed torouters/analytics.py(which still exportsthe
aggregation_routersymbol), butspp_api_v2_simulation/models/fastapi_endpoint.pywas not updated —_get_fastapi_routers()still ranfrom ..routers.aggregation import aggregation_router._get_fastapi_routers()runs during FastAPI app construction, which the dispatcher performs for arequest to the API root before endpoint-level OAuth/JWT checks. So the stale import raises
ModuleNotFoundErrorand aborts app creation: an unauthenticated request to the public API V2 routecan trigger it, and after a restart or cache miss the entire API V2 endpoint is effectively unavailable.
The broken import shipped in the released
2026.07tag, and no existing test built the app(
test_router_coverage.pyimports router helpers directly), so it went uncaught. Severity: medium(unauthenticated availability/DoS of all of API V2).
Fix
One line: import
aggregation_routerfrom..routers.analytics(the canonical current module) instead ofthe removed
..routers.aggregation. The symbol name and/aggregationprefix are unchanged; nocompatibility-wrapper module (that would be cruft). No schema change → no migration.
Tests
Test-first (red → green). New
tests/test_fastapi_router_inclusion.pyfetches theapi_v2fastapi.endpoint, calls_get_fastapi_routers()(must not raise), and asserts the/aggregationrouteris included. Before the fix it errored with
ModuleNotFoundError: No module named 'odoo.addons.spp_api_v2_simulation.routers.aggregation'(1 error of179); after the fix
./spp t spp_api_v2_simulation→ 0 failed of 179. No existing tests changed.Notes
19.0.2.0.0 → 19.0.2.0.1;README.rst/static/description/index.htmlto be regeneratedfrom CI's pinned generator.
spp_api_v2_simulation.