179 bug UI projects not calling fastapi projects endpoint#180
Open
atriaybagur wants to merge 13 commits intodevelopfrom
Open
179 bug UI projects not calling fastapi projects endpoint#180atriaybagur wants to merge 13 commits intodevelopfrom
atriaybagur wants to merge 13 commits intodevelopfrom
Conversation
Route /projects, /users, and /roles collection API traffic cleanly by: - forwarding API paths with dedicated ALB listener rules - reserving SPA page routes like /projects for the frontend - switching frontend collection requests to slash-suffixed endpoints (/projects/, /users/, /roles/) Also update Cypress intercepts to match the new collection endpoint paths.
2 tasks
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ensitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…ine 493) - making trust-service.ts (line 24) return [] if the payload is not an array - hardening ProjectStaging.vue (line 137) so it won’t crash even if the store is corrupted
…s-not-calling-fastapi-projects-endpoint
- Updated test cases in project_services, site_services, trusts_services, and user_services to use the new '/api' prefix for all API calls. - Adjusted the base URL in the frontend configuration to reflect the '/api' prefix. - Modified Cypress tests to ensure they align with the updated API endpoint structure. - Ensured all relevant documentation reflects the changes in API endpoint structure.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ints-to-avoid-ui-conflicts 179 atb reroute api endpoints to avoid UI conflicts
There was a problem hiding this comment.
Pull request overview
This PR standardizes the CentralHub API under a shared /api namespace and updates UI configuration, automated tests, and AWS deployment routing to match the new URL structure.
Changes:
- Mount all
flip-apirouters under/apiand move health/docs endpoints to/api/*. - Update
flip-uiand environment/config docs to treat the backend base URL as including/api. - Update API consumer tests (unit/integration) and AWS ALB routing/health checks to use
/api/*.
Reviewed changes
Copilot reviewed 48 out of 49 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| flip-ui/test/cypress/support/globalIntercepts.ts | Cypress intercept stubs for UI E2E tests (currently still using unprefixed paths). |
| flip-ui/src/services/trust-service.ts | Adds defensive handling when /trust response is not an array. |
| flip-ui/src/partials/projects/ProjectStaging.vue | Adds defensive handling when trustStore.getTrusts is not an array. |
| flip-ui/README.md | Clarifies VITE_AWS_BASE_URL should include /api. |
| flip-ui/public/js/window.js | Updates default runtime AWS_BASE_URL to include /api. |
| flip-ui/CONTRIBUTING.md | Updates local setup docs to use /api in VITE_AWS_BASE_URL. |
| flip-ui/api/server.ts | Minor formatting cleanup in mock server routes. |
| flip-api/tests/unit/user_services/test_update_user.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/user_services/test_get_users.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/user_services/test_access_request.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/trusts_services/test_trusts_health_check.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/trusts_services/test_get_trusts.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/site_services/test_details.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/project_services/test_unstage_project.py | Adds /api router prefix in fixture and updates test endpoints. |
| flip-api/tests/unit/project_services/test_stage_project.py | Adds /api router prefix in fixture and updates test endpoints. |
| flip-api/tests/unit/project_services/test_get_project.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/project_services/test_get_project_approved_trusts.py | Adds /api router prefix in fixture and updates test endpoints. |
| flip-api/tests/unit/project_services/test_get_models.py | Adds /api router prefix in fixture and updates test endpoints. |
| flip-api/tests/unit/project_services/test_get_imaging_project_status.py | Adds /api router prefix in fixture; updates invalid UUID expectation to 422. |
| flip-api/tests/unit/project_services/test_delete_project.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/private_services/test_save_training_metrics.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/private_services/test_invoke_model_status_update.py | Adds /api router prefix in fixture and updates test endpoints. |
| flip-api/tests/unit/model_services/test_update_model_status.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/model_services/test_save_model.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/model_services/test_retrieve_trusts_in_model.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/model_services/test_retrieve_logs_for_model.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/model_services/test_get_metrics.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/model_services/test_edit_model.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/model_services/test_delete_model.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/file_services/test_retrieve_federated_results.py | Updates test endpoints to /api/*. |
| flip-api/tests/unit/db/seed/test_trusts.py | Updates expected log message for skipped trust seeding. |
| flip-api/tests/step_functions_services/test_retrieve_model_step_function.py | Updates test endpoints to /api/*. |
| flip-api/tests/step_functions_services/test_register_user_step_function.py | Updates test endpoints to /api/*. |
| flip-api/tests/step_functions_services/test_cohort_query_step_function.py | Updates test endpoints to /api/*. |
| flip-api/tests/step_functions_services/test_approve_project_step_function.py | Updates test endpoints to /api/*. |
| flip-api/tests/integration/test_user_registration_real_api.py | Updates integration test endpoint to /api/*. |
| flip-api/tests/integration/test_retrieve_uploaded_file_info.py | Updates integration test endpoint to /api/*. |
| flip-api/src/flip_api/utils/constants.py | Updates test base URL constant to include /api. |
| flip-api/src/flip_api/user_services/get_users.py | Changes route path from / to empty path under router prefix (to avoid trailing slash). |
| flip-api/src/flip_api/role_services/get_roles.py | Changes route path from / to empty path under router prefix (to avoid trailing slash). |
| flip-api/src/flip_api/project_services/get_projects.py | Changes route path from / to empty path under router prefix (to avoid trailing slash). |
| flip-api/src/flip_api/project_services/create_project.py | Changes route path from / to empty path under router prefix (to avoid trailing slash). |
| flip-api/src/flip_api/main.py | Introduces API_PREFIX = /api, mounts all routers under it, and moves root/health/docs/openapi under /api/*. |
| flip-api/src/flip_api/db/seed/trusts.py | Broadens exception handling/logging during trust seeding (now swallows all exceptions). |
| flip-api/src/flip_api/config.py | Updates test-only FLIP_API_URL default to include /api. |
| deploy/providers/AWS/update_env.py | Updates CENTRAL_HUB_API_URL to include /api. |
| deploy/providers/AWS/main.tf | Updates ALB routing to forward /api namespace and sets target group health check to /api/health. |
| deploy/providers/AWS/check_status.py | Updates health/docs checks to /api/*. |
| .env.development.example | Updates example UI/API base URLs to include /api. |
Comment on lines
50
to
56
| cy.intercept( | ||
| "GET", | ||
| "/projects?pageNumber=1&pageSize=20", { | ||
| statusCode: 200, | ||
| fixture: "project/getProjects" | ||
| } | ||
| statusCode: 200, | ||
| fixture: "project/getProjects" | ||
| } | ||
| ).as("getProjectsGlobal"); |
Comment on lines
47
to
53
| # Create new trust | ||
| new_trust = Trust(name=trust_name, endpoint=endpoint) | ||
| session.add(new_trust) | ||
| except Exception as e: | ||
| except Exception: | ||
| # If the endpoint is not found in secrets, skip this trust | ||
| logger.info(f"Endpoint for {trust_name} not found in secrets. Skipping. Error: {e}") | ||
| logger.info("Endpoint not found in secrets for one of the trusts. Skipping.") | ||
| continue |
Comment on lines
212
to
222
| # Root endpoint | ||
| @app.get("/", response_model=dict[str, str]) | ||
| @app.get(API_PREFIX, response_model=dict[str, str]) | ||
| def root(): | ||
| """Root endpoint to verify the API is running.""" | ||
| return {"message": "Welcome to flip"} | ||
|
|
||
|
|
||
| @app.get("/health", response_model=dict[str, str]) | ||
| @app.get(f"{API_PREFIX}/health", response_model=dict[str, str]) | ||
| def health_check(): | ||
| """Health check endpoint to verify the API is running""" | ||
| return {"status": "ok", "message": "flip is running"} |
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.
Test using the following in FLIP UI Docker image in deploy/compose.production.yml :
(built in this workflow run)
Now the UI page https://stag.flip.aicentre.co.uk/projects calls the flip-api endpoint:
Fixes /projects page, /users page, cohort queries (/step routers)
Trained the spleen segmentation model end-to-end:

This pull request introduces several improvements and fixes across the infrastructure, backend, frontend, and test codebases. The main focus is on standardizing API endpoint paths (especially adding trailing slashes for collection endpoints), improving listener rule routing in AWS Terraform configuration, and enhancing robustness and error handling for trust-related features. These changes help ensure consistent API behavior, better routing, and more reliable UI and backend interactions.
Infrastructure and API Routing
main.tfto use more specific path patterns for API endpoints, including splitting role endpoints into their own rule and expanding trust/site/step endpoint coverage. This improves routing precision and maintainability. [1] [2]/users,/projects, and/rolesto always include a trailing slash in listener rules, aligning with SPA routing requirements and preventing conflicts between frontend and backend routes.Frontend Consistency and Robustness
/users,/projects, and/rolesto use trailing slashes for collection endpoints, ensuring consistency with backend routing and preventing subtle bugs. [1] [2] [3] [4]Test Suite Updates
Backend Error Handling