Skip to content

Conversation

@pcrespov
Copy link
Member

@pcrespov pcrespov commented Oct 8, 2025

What do these changes do?

The main motiviation to this PR was to fix the 503 response from get_project_services in the web-api when a service listed in one of the project nodes is not anymore part of the catalog.

We took the opportunity to:

  • Introduces generic batch operations models for handling partial success scenarios (for any interface)
  • Updates the API to return missing services in addition to found ones
  • Refactors batch-get operations throughout the catalog service to use the new envelope pattern

Highlights

  • 🐛 Fixes 503 response from GET /v0/projects/{project_id}/nodes/-/services when one of the services in the project was not found int he catalog:
{
  "error_code": "OEC:83e338830cbb-1759912388229",
  "context": {
    "request": "<Request GET /v0/projects/fe9494f6-e2ad-5970-b860-e6cb97dc25ce/nodes/-/services >",
    "request.method": "GET",
    "request.path": "/v0/projects/fe9494f6-e2ad-5970-b860-e6cb97dc25ce/nodes/-/services",
    "error_code": "OEC:83e338830cbb-1759912388229",
    "user_id": 6,
    "product_name": "osparc",
    "services_ids": [
      [
        "simcore/services/dynamic/cc-1d-viewer",
        "3.0.3"
      ],
      [
        "simcore/services/frontend/file-picker",
        "1.0.0"
      ],
      [
        "simcore/services/comp/rabbit-ss-0d-cardiac-model",
        "1.0.0"
      ],
      [
        "simcore/services/comp/rabbit-ss-1d-cardiac-model",
        "1.0.0"
      ],
      [
        "simcore/services/comp/rabbit-ss-2d-cardiac-model",
        "1.0.0"
      ],
      [
        "simcore/services/dynamic/cc-0d-viewer",
        "3.0.3"  <----------this was not in the catalog
      ]
    ],
    "message": "Catalog service failed unexpectedly",
    "code": "CatalogApiBaseError.CatalogNotAvailableError"
  },
  "tip": null
}

This is because the underlying batch-get operations did not allow partial failure and one of the services in the project is not in the catalog.

Now that endpoints returns missing services in the response payload (see changes in OAS)

  • ✨ introduces generics to build models for batch operations
  • @odeimaiz new missing field in the GET /v0/projects/{project_id}/nodes/-/services response model that include a list of key/value tuples of missing services
image

In Detail (AI generated)

This pull request introduces a new generic batch-get envelope model for service retrieval operations, enabling partial success responses and improved error handling when some requested services are missing. It refactors the batch-get endpoints and service logic to use this new model, ensures deduplication and validation of input identifiers, and updates related error handling and tests to reflect these changes.

Batch-get envelope and validation improvements

  • Added a generic BatchGetEnvelope model and a create_batch_ids_validator utility in batch_operations.py to support partial results and deduplicate input identifiers for batch operations.
  • Updated the catalog service API schemas to use MyServicesRpcBatchGet, which returns both found and missing services, replacing the previous list-based response. [1] [2]

Service logic and error handling

  • Refactored batch_get_user_services and related endpoints to use the new envelope model, handle missing services gracefully, and raise a new CatalogServiceNotFoundError when no services are found. [1] [2] [3] [4] [5]
  • Introduced CatalogBadRequestError and improved error templates for catalog-related exceptions.

API and test updates

  • Updated API endpoints and RPC interfaces to return the new batch-get envelope, including changes in the webserver project node schema for missing services. [1] [2] [3] [4] [5] [6] [7]
  • Added comprehensive tests for batch identifier validation and updated service catalog tests to check for missing identifiers in batch-get results. [1] [2] [3] [4]

Type aliasing and code organization

  • Introduced BatchGetUserServicesResult type alias for future-proofing schema/domain separation.
  • Improved code organization by importing new utilities and error types where needed. [1] [2]

Related issue/s

  • Found in logs of staging deploy

How to test

  • models_library: new generic batch-operations models and utils
    - packages/models-library/tests/test_batch_operations.py for new generic models and utils
  • web-server services
    • rest api: services/web/server/tests/unit/with_dbs/02/test_projects_nodes_handlers__services_access.py
  • catalog services
    • service layer: services/catalog/tests/unit/with_dbs/test_service_catalog_services.py
    • rpc client: services/catalog/tests/unit/with_dbs/test_api_rpc.py

Dev-ops

None

@pcrespov pcrespov self-assigned this Oct 8, 2025
@codecov
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

❌ Patch coverage is 79.03226% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.35%. Comparing base (ff5ca9c) to head (407c7a3).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8486      +/-   ##
==========================================
- Coverage   87.62%   87.35%   -0.27%     
==========================================
  Files        1999     1654     -345     
  Lines       77828    67797   -10031     
  Branches     1338     1004     -334     
==========================================
- Hits        68193    59227    -8966     
+ Misses       9235     8260     -975     
+ Partials      400      310      -90     
Flag Coverage Δ *Carryforward flag
integrationtests 64.17% <ø> (+0.07%) ⬆️ Carriedforward from 3319147
unittests 85.85% <79.03%> (-0.48%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
pkg_aws_library ∅ <ø> (∅)
pkg_celery_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library 93.06% <90.90%> (-0.01%) ⬇️
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration 70.17% <ø> (ø)
pkg_service_library 70.96% <0.00%> (-0.03%) ⬇️
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 84.95% <ø> (-0.06%) ⬇️
agent 93.10% <ø> (ø)
api_server 91.88% <ø> (ø)
autoscaling 95.72% <ø> (ø)
catalog 92.06% <85.00%> (-0.22%) ⬇️
clusters_keeper 99.14% <ø> (ø)
dask_sidecar 92.37% <ø> (ø)
datcore_adapter 97.95% <ø> (ø)
director 75.72% <ø> (ø)
director_v2 90.94% <ø> (+0.05%) ⬆️
dynamic_scheduler ∅ <ø> (∅)
dynamic_sidecar 90.44% <ø> (ø)
efs_guardian 89.83% <ø> (ø)
invitations 90.90% <ø> (ø)
payments 92.80% <ø> (ø)
resource_usage_tracker 92.11% <ø> (-0.11%) ⬇️
storage ∅ <ø> (∅)
webclient ∅ <ø> (∅)
webserver 87.32% <90.90%> (+0.04%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff5ca9c...407c7a3. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mergify
Copy link
Contributor

mergify bot commented Oct 8, 2025

🧪 CI Insights

Here's what we observed from your CI run for 407c7a3.

❌ Job Failures

Pipeline Job Health on master Retries 🔍 CI Insights 📄 Logs
CI build-test-images (frontend) / build-test-images Healthy 0 View View
unit-tests Healthy 0 View View

@pcrespov pcrespov changed the title 🐛 Fix/catalog batch service 🐛 Fixes webserver-api 503 on projects/{project_id}/nodes/-/services when project services are missing in the catalog Oct 8, 2025
@pcrespov pcrespov changed the title 🐛 Fixes webserver-api 503 on projects/{project_id}/nodes/-/services when project services are missing in the catalog 🐛 Fixes webserver-api error on get_project_services when project services are missing in the catalog by allowing partial failure Oct 8, 2025
@pcrespov pcrespov added this to the Cheops milestone Oct 8, 2025
@pcrespov pcrespov added a:webserver webserver's codebase. Assigning the area is particularly useful for bugs a:models-library labels Oct 8, 2025
@pcrespov pcrespov force-pushed the fix/catalog-batch-service branch from 389ab4a to a32fc97 Compare October 8, 2025 17:30
@pcrespov pcrespov marked this pull request as ready for review October 8, 2025 17:30
@pcrespov pcrespov requested review from Copilot and odeimaiz October 8, 2025 17:30
Copy link
Contributor

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 fixes a bug where the GET /v0/projects/{project_id}/nodes/-/services endpoint returned a 503 error when project services were missing from the catalog. The fix introduces support for partial failure handling by returning both found and missing services in the response.

  • Introduces generic batch operations models for handling partial success scenarios
  • Updates the API to return missing services in addition to found ones
  • Refactors batch-get operations throughout the catalog service to use the new envelope pattern

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/models-library/src/models_library/batch_operations.py Adds generic BatchGetEnvelope model and validation utilities for batch operations
packages/models-library/src/models_library/api_schemas_catalog/services.py Introduces MyServicesRpcBatchGet schema using the new batch envelope pattern
packages/models-library/src/models_library/api_schemas_webserver/projects_nodes.py Adds missing field to ProjectNodeServicesGet for tracking services not found in catalog
services/catalog/src/simcore_service_catalog/service/catalog_services.py Refactors batch_get_user_services to return envelope with found and missing items
services/catalog/src/simcore_service_catalog/repository/services.py Updates batch_get_services_access_rights to return None when no services found
services/web/server/src/simcore_service_webserver/projects/_controller/nodes_rest.py Updates get_project_services to handle the new batch envelope response
Multiple test files Updates tests to work with new batch envelope response format
Multiple error handling files Renames RPC error classes with "Rpc" suffix for consistency
Comments suppressed due to low confidence (1)

services/catalog/src/simcore_service_catalog/service/catalog_services.py:1

  • The assertion compares found items to all input ids, but this will fail when some services are missing. Should compare to deduplicated ids or remove assertion entirely since partial success is now supported.
"""Includes manifest (services in the registry) and function-service (front-end/back-end services)"""

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pcrespov pcrespov force-pushed the fix/catalog-batch-service branch from 9fb4957 to cfd0ab0 Compare October 8, 2025 17:52
@pcrespov pcrespov enabled auto-merge (squash) October 8, 2025 17:54
Copy link
Contributor

@wvangeit wvangeit left a comment

Choose a reason for hiding this comment

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

Thanks

Copy link
Member

@odeimaiz odeimaiz left a comment

Choose a reason for hiding this comment

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

thx

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

👍

@pcrespov pcrespov force-pushed the fix/catalog-batch-service branch from 5c53092 to 9a4b982 Compare October 9, 2025 13:00
@pcrespov pcrespov force-pushed the fix/catalog-batch-service branch from 9a4b982 to 5fd0e88 Compare October 9, 2025 13:37
@pcrespov
Copy link
Member Author

pcrespov commented Oct 9, 2025

@mergify queue

@pcrespov pcrespov added the 🤖-automerge marks PR as ready to be merged for Mergify label Oct 9, 2025
@mergify
Copy link
Contributor

mergify bot commented Oct 9, 2025

queue

🟠 Waiting for conditions to match

  • -closed [📌 queue requirement]
  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default]
      • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
      • any of: [🛡 GitHub branch protection]
        • check-neutral = deploy to dockerhub
        • check-skipped = deploy to dockerhub
        • check-success = deploy to dockerhub
      • any of: [🛡 GitHub branch protection]
        • check-neutral = unit-tests
        • check-skipped = unit-tests
        • check-success = unit-tests
      • any of: [🛡 GitHub branch protection]
        • check-neutral = build-test-images (frontend) / build-test-images
        • check-skipped = build-test-images (frontend) / build-test-images
        • check-success = build-test-images (frontend) / build-test-images
      • #approved-reviews-by >= 2 [🛡 GitHub branch protection]
      • #approved-reviews-by>=2
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
      • #review-threads-unresolved=0
      • -conflict
      • -draft
      • base=master
      • label!=🤖-do-not-merge
      • label=🤖-automerge
      • any of: [🛡 GitHub branch protection]
        • check-success = system-tests
        • check-neutral = system-tests
        • check-skipped = system-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = check OAS' are up to date
        • check-neutral = check OAS' are up to date
        • check-skipped = check OAS' are up to date
      • any of: [🛡 GitHub branch protection]
        • check-success = integration-tests
        • check-neutral = integration-tests
        • check-skipped = integration-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = SonarCloud Code Analysis
        • check-neutral = SonarCloud Code Analysis
        • check-skipped = SonarCloud Code Analysis
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of: [📌 queue -> configuration change requirements]
    • -mergify-configuration-changed
    • check-success = Configuration changed

@pcrespov pcrespov disabled auto-merge October 9, 2025 15:45
@pcrespov pcrespov merged commit e6e1581 into ITISFoundation:master Oct 9, 2025
1 check was pending
@pcrespov pcrespov deleted the fix/catalog-batch-service branch October 9, 2025 15:45
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-automerge marks PR as ready to be merged for Mergify a:models-library a:webserver webserver's codebase. Assigning the area is particularly useful for bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants