Skip to content

179 bug UI projects not calling fastapi projects endpoint#180

Open
atriaybagur wants to merge 13 commits intodevelopfrom
179-bug-ui-projects-not-calling-fastapi-projects-endpoint
Open

179 bug UI projects not calling fastapi projects endpoint#180
atriaybagur wants to merge 13 commits intodevelopfrom
179-bug-ui-projects-not-calling-fastapi-projects-endpoint

Conversation

@atriaybagur
Copy link
Member

@atriaybagur atriaybagur commented Mar 16, 2026

Test using the following in FLIP UI Docker image in deploy/compose.production.yml :

image: ghcr.io/londonaicentre/flip-ui:179

(built in this workflow run)

Now the UI page https://stag.flip.aicentre.co.uk/projects calls the flip-api endpoint:

      INFO   10.0.2.247:56476 - "GET /projects/?pageNumber=1&pageSize=20        
             HTTP/1.1" 200

Fixes /projects page, /users page, cohort queries (/step routers)


⚠️ note in the future we could have all of the backend endpoints under /api/* -- then the listener becomes much simpler and avoids conflicts with frontend -- it's also more maintainable if we add new routes !

Right now main.tf is compensating for a design issue: the SPA and API both live at the site root, so routes like /projects, /model, /trust, /step/... keep colliding. Putting the API under /api/* would let the ALB use essentially one rule for the app API and avoid all these special cases.

condition {
  path_pattern {
    values = ["/api/*", "/docs", "/openapi.json", "/redoc"]
  }
}

Screenshot 2026-03-16 at 22 54 41 Screenshot 2026-03-16 at 23 18 51 Screenshot 2026-03-16 at 23 19 00

Trained the spleen segmentation model end-to-end:
Screenshot 2026-03-17 at 11 17 46


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

  • Updated AWS Load Balancer listener rules in main.tf to 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]
  • Standardized collection endpoint paths for /users, /projects, and /roles to 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

  • Updated all frontend API calls for /users, /projects, and /roles to use trailing slashes for collection endpoints, ensuring consistency with backend routing and preventing subtle bugs. [1] [2] [3] [4]
  • Improved trust-related UI components and services to handle cases where the trust list is not an array, preventing errors and ensuring graceful fallback. [1] [2]

Test Suite Updates

Backend Error Handling

  • Improved exception handling in trust seeding logic to log a generic message when an endpoint is missing, avoiding leaking exception details and simplifying log output. Corresponding test assertion updated for new log message. [1] [2]

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.
@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
flip-ui/public/js/window.js 0.00% 1 Missing ⚠️
flip-ui/src/services/trust-service.ts 0.00% 1 Missing ⚠️

📢 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
@atriaybagur atriaybagur changed the base branch from main to develop March 16, 2026 23:16
@atriaybagur atriaybagur changed the base branch from develop to 4-feature-fl-port-consolidation March 16, 2026 23:17
@atriaybagur atriaybagur requested a review from garciadias March 16, 2026 23:18
@atriaybagur atriaybagur changed the base branch from 4-feature-fl-port-consolidation to develop March 17, 2026 11:18
atriaybagur and others added 6 commits March 17, 2026 15:57
- 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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-api routers under /api and move health/docs endpoints to /api/*.
  • Update flip-ui and 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"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: UI /projects not calling FastAPI /projects endpoint

3 participants