[FIX][API]: extract resolve_root_path into shared utils/paths module#3337
[FIX][API]: extract resolve_root_path into shared utils/paths module#3337prashantgupta24 wants to merge 14 commits intoIBM:mainfrom
Conversation
Signed-off-by: Prashant Gupta <prashantgupta@us.ibm.com>
|
Thanks @prashantgupta24. This is a clean DRY refactoring — the shared |
Signed-off-by: Prashant Gupta <prashantgupta@us.ibm.com>
Signed-off-by: Prashant Gupta <prashantgupta@us.ibm.com>
Signed-off-by: Prashant Gupta <prashantgupta@us.ibm.com>
Resolved import conflicts in oauth_router.py and sso.py by keeping both imports (resolve_root_path and sanitize_for_log) as both are needed. Signed-off-by: Prashant Gupta <prashantgupta@us.ibm.com>
|
@prashantgupta24 Can you please rebase your branch. ✅ Required Fixes
The PR description shows empty verification status. Please run and confirm all pass:
Line 12-13: References "PR #3297" but this is PR #3337 fixing issue #3298. Please correct or clarify. Suggested fix: Old:that was previously private to
|
Signed-off-by: Prashant Gupta <prashantgupta@us.ibm.com>
|
@rakdutta done ✅ |
|
Overall: Excellent refactoring that consolidates root path resolution into a shared utility. Well-tested and follows all project conventions. Strengths
Minor Suggestions
Risk Assessment Low - Pure structural refactoring with no logic changes beyond consolidation. Excellent test coverage ensures correctness. @prashantgupta24 Could you please fix the failing test cases before proceeding with the merge? After setting APP_ROOT_PATH="/proxy/mcp" and running pytest, the following tests are failing due to a mismatch in the expected redirect paths: FAILED tests/unit/mcpgateway/test_admin.py::TestAdminServerRoutes::test_admin_set_server_state_activate - AssertionError: assert '/proxy/mcp/admin#catalog' == '/admin#catalog' |
🔗 Related Issue
Closes #3298
📝 Summary
All 12
request.scope.get("root_path", "")call sites across 5 files now use the sharedresolve_root_path()utility with propersettings.app_root_pathfallback.New file created:
resolve_root_path(request)helper (mirrors the logic fromadmin.py's_resolve_root_path, with 17 passing doctests)Files updated (Option 1 — DRY approach):
_resolve_root_path()definition withfrom mcpgateway.utils.paths import resolve_root_path as _resolve_root_path; all existing call sites unchanged🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes (optional)
Screenshots, design decisions, or additional context.