diff --git a/services/api-server/src/simcore_service_api_server/api/routes/solvers.py b/services/api-server/src/simcore_service_api_server/api/routes/solvers.py index be6e092b735b..3998102a97f9 100644 --- a/services/api-server/src/simcore_service_api_server/api/routes/solvers.py +++ b/services/api-server/src/simcore_service_api_server/api/routes/solvers.py @@ -6,6 +6,7 @@ from httpx import HTTPStatusError from pydantic import ValidationError from pydantic.errors import PydanticValueError +from servicelib.error_codes import create_error_code from ...core.settings import ApplicationSettings, BasicSettings from ...models.schemas.solvers import Solver, SolverKeyId, SolverPort, VersionStr @@ -191,10 +192,20 @@ async def list_solver_ports( ) return ports - except ( - ValidationError, - HTTPStatusError, - ) as err: + except ValidationError as err: + error_code = create_error_code(err) + logger.exception( + "Corrupted port data for service %s [%s]", + f"{solver_key}:{version}", + f"{error_code}", + extra={"error_code": error_code}, + ) + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Port definition of {solver_key}:{version} seems corrupted [{error_code}]", + ) from err + + except HTTPStatusError as err: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail=f"Ports for solver {solver_key}:{version} not found", diff --git a/services/api-server/src/simcore_service_api_server/models/schemas/solvers.py b/services/api-server/src/simcore_service_api_server/models/schemas/solvers.py index 50ff8549cfde..fd0bb9a628a5 100644 --- a/services/api-server/src/simcore_service_api_server/models/schemas/solvers.py +++ b/services/api-server/src/simcore_service_api_server/models/schemas/solvers.py @@ -111,17 +111,23 @@ def compose_resource_name(cls, solver_key, solver_version) -> str: class SolverPort(BaseModel): - name: str = Field( - ..., description="port identifier name", regex=PUBLIC_VARIABLE_NAME_RE + key: str = Field( + ..., + description="port identifier name", + regex=PUBLIC_VARIABLE_NAME_RE, + title="Key name", ) kind: PortKindStr - content_schema: Optional[dict[str, Any]] = None + content_schema: Optional[dict[str, Any]] = Field( + None, + description="jsonschema for the port's value. SEE https://json-schema.org", + ) class Config: extra = Extra.ignore schema_extra = { "example": { - "name": "input_2", + "key": "input_2", "kind": "input", "content_schema": { "title": "Sleep interval", diff --git a/services/api-server/tests/unit/api_solvers/test_api_routers_solvers.py b/services/api-server/tests/unit/api_solvers/test_api_routers_solvers.py index 4b884cb87e51..d35c2c30d347 100644 --- a/services/api-server/tests/unit/api_solvers/test_api_routers_solvers.py +++ b/services/api-server/tests/unit/api_solvers/test_api_routers_solvers.py @@ -76,7 +76,7 @@ async def test_list_solver_ports( assert resp.json() == [ { - "name": "input_1", + "key": "input_1", "kind": "input", "content_schema": { "title": "Sleep interval",