Skip to content

Commit 870b9b2

Browse files
♻️ Currently frontend is expecting status field in error response body (#7256)
1 parent b084481 commit 870b9b2

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

packages/models-library/src/models_library/rest_error.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ class ErrorGet(BaseModel):
7575
IDStr | None,
7676
Field(description="ID to track the incident during support", alias="supportId"),
7777
] = None
78+
status: int
7879

7980
# NOTE: The fields blow are DEPRECATED. Still here to keep compatibilty with front-end until updated
80-
status: Annotated[int, Field(deprecated=True)] = 400
8181
errors: Annotated[
8282
list[ErrorItemType],
8383
Field(deprecated=True, default_factory=list, json_schema_extra={"default": []}),
@@ -94,11 +94,13 @@ class ErrorGet(BaseModel):
9494
json_schema_extra={
9595
"examples": [
9696
{
97-
"message": "Sorry you do not have sufficient access rights for product"
97+
"message": "Sorry you do not have sufficient access rights for product",
98+
"status": 401,
9899
},
99100
{
100101
"message": "Opps this error was unexpected. We are working on that!",
101102
"supportId": "OEC:12346789",
103+
"status": 500,
102104
},
103105
]
104106
},
@@ -111,9 +113,13 @@ class EnvelopedError(Envelope[None]):
111113
model_config = ConfigDict(
112114
json_schema_extra={
113115
"examples": [
114-
{"error": {"message": "display error message here"}},
116+
{"error": {"message": "display error message here", "status": 401}},
115117
{
116-
"error": {"message": "failure", "supportId": "OEC:123455"},
118+
"error": {
119+
"message": "failure",
120+
"supportId": "OEC:123455",
121+
"status": 500,
122+
},
117123
"data": None,
118124
},
119125
]

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10021,8 +10021,6 @@ components:
1002110021
status:
1002210022
type: integer
1002310023
title: Status
10024-
default: 400
10025-
deprecated: true
1002610024
errors:
1002710025
items:
1002810026
$ref: '#/components/schemas/ErrorItemType'
@@ -10040,6 +10038,7 @@ components:
1004010038
type: object
1004110039
required:
1004210040
- message
10041+
- status
1004310042
title: ErrorGet
1004410043
ErrorItemType:
1004510044
properties:

services/web/server/src/simcore_service_webserver/exception_handling/_factory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def _exception_handler(
8080
_DefaultDict(getattr(exception, "__dict__", {}))
8181
)
8282

83-
error = ErrorGet.model_construct(message=user_msg)
83+
error = ErrorGet.model_construct(message=user_msg, status=status_code)
8484

8585
if is_5xx_server_error(status_code):
8686
oec = create_error_code(exception)
@@ -100,7 +100,9 @@ async def _exception_handler(
100100
},
101101
)
102102
)
103-
error = ErrorGet.model_construct(message=user_msg, support_id=oec)
103+
error = ErrorGet.model_construct(
104+
message=user_msg, support_id=oec, status=status_code
105+
)
104106

105107
return create_error_response(error, status_code=status_code)
106108

0 commit comments

Comments
 (0)