Skip to content

Commit 961c173

Browse files
authored
🎨 web-api: New batch of improved user-facing messages (#7944)
1 parent 0571243 commit 961c173

File tree

23 files changed

+367
-175
lines changed

23 files changed

+367
-175
lines changed

.github/prompts/update-user-messages.prompt.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ error_msg = user_message("Operation failed. Please try again later.")
1818

1919
## Guidelines for Updating User Messages
2020

21-
When modifying user messages, follow these rules:
21+
When modifying user messages, follow **as close as possible** these rules:
2222

2323
1. **Version Tracking**: Every modification to a user message must include an incremented `_version` parameter:
2424

@@ -43,7 +43,7 @@ When modifying user messages, follow these rules:
4343
user_message("Unable to load project.", _version=1)
4444
```
4545

46-
3. **Message Style**: Follow *strictly* the guidelines in `${workspaceFolder}/docs/user-messages-guidelines.md`
46+
3. **Message Style**: Follow **strictly** the guidelines in `${workspaceFolder}/docs/user-messages-guidelines.md`
4747

4848
4. **Preserve Context**: Ensure the modified message conveys the same meaning and context as the original.
4949

@@ -56,17 +56,19 @@ When modifying user messages, follow these rules:
5656
# After
5757
user_message("Your session has expired. Please log in again.", _version=3)
5858
```
59+
6. **Replace 'Study' by 'Project'**: If the message contains the word 'Study', replace it with 'Project' to align with our terminology.
60+
5961

6062
## Examples
6163

6264
### Example 1: Simple Message Update
6365

6466
```python
6567
# Before
66-
error_dialog(user_message("Failed to save changes."))
68+
error_dialog(user_message("Failed to save changes in this study."))
6769

6870
# After
69-
error_dialog(user_message("Unable to save your changes. Please try again.", _version=1))
71+
error_dialog(user_message("Unable to save your changes in this project.", _version=1))
7072
```
7173

7274
### Example 2: F-string Message Update

packages/service-library/src/servicelib/aiohttp/rest_middlewares.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
DEFAULT_API_VERSION = "v0"
3737
_FMSG_INTERNAL_ERROR_USER_FRIENDLY = user_message(
3838
"We apologize for the inconvenience. "
39-
"The issue has been recorded, please report it if it persists."
39+
"The issue has been recorded, please report it if it persists.",
40+
_version=1,
4041
)
4142

4243

services/web/server/src/simcore_service_webserver/catalog/_constants.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from typing import Final
22

3+
from common_library.user_messages import user_message
4+
35
from ..constants import MSG_TRY_AGAIN_OR_SUPPORT
46

5-
MSG_CATALOG_SERVICE_UNAVAILABLE: Final[str] = (
7+
MSG_CATALOG_SERVICE_UNAVAILABLE: Final[str] = user_message(
68
# Most likely the director service is down or misconfigured so the user is asked to try again later.
7-
"This service is temporarily unavailable. The incident was logged and will be investigated. "
8-
+ MSG_TRY_AGAIN_OR_SUPPORT
9+
"The catalog service is currently unavailable. This issue has been logged and will be investigated. "
10+
+ MSG_TRY_AGAIN_OR_SUPPORT,
11+
_version=1,
912
)
1013

1114

services/web/server/src/simcore_service_webserver/constants.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pylint:disable=unused-import
22

3+
from sys import version
34
from typing import Final
45

56
from common_library.user_messages import user_message
@@ -39,7 +40,7 @@
3940
# main index route name = front-end
4041
INDEX_RESOURCE_NAME: Final[str] = "get_cached_frontend_index"
4142

42-
MSG_UNDER_DEVELOPMENT: Final[str] = (
43+
MSG_UNDER_DEVELOPMENT: Final[str] = user_message(
4344
"Under development. Use WEBSERVER_DEV_FEATURES_ENABLED=1 to enable current implementation"
4445
)
4546

@@ -48,7 +49,7 @@
4849

4950

5051
MSG_TRY_AGAIN_OR_SUPPORT: Final[str] = user_message(
51-
"Please try again shortly. If the issue persists, contact support."
52+
"Please try again shortly. If the issue persists, contact support.", _version=1
5253
)
5354

5455
__all__: tuple[str, ...] = (

services/web/server/src/simcore_service_webserver/director_v2/_controller/_rest_exceptions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,17 @@ async def _handler_director_service_error_as_503_or_4xx(
8787
_TO_HTTP_ERROR_MAP: ExceptionToHttpErrorMap = {
8888
UserDefaultWalletNotFoundError: HttpErrorInfo(
8989
status.HTTP_404_NOT_FOUND,
90-
user_message("Default wallet not found but necessary for computations"),
90+
user_message(
91+
"A default wallet is required for running computations but could not be found.",
92+
_version=1,
93+
),
9194
),
9295
WalletNotEnoughCreditsError: HttpErrorInfo(
9396
status.HTTP_402_PAYMENT_REQUIRED,
94-
user_message("Wallet does not have enough credits for computations. {reason}"),
97+
user_message(
98+
"Your wallet does not have sufficient credits to run this computation. {reason}",
99+
_version=1,
100+
),
95101
),
96102
}
97103

services/web/server/src/simcore_service_webserver/folders/_common/exceptions_handlers.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,49 +32,56 @@
3232
_TO_HTTP_ERROR_MAP: ExceptionToHttpErrorMap = {
3333
FolderNotFoundError: HttpErrorInfo(
3434
status.HTTP_404_NOT_FOUND,
35-
user_message("Folder was not found"),
35+
user_message("The requested folder could not be found.", _version=1),
3636
),
3737
WorkspaceNotFoundError: HttpErrorInfo(
3838
status.HTTP_404_NOT_FOUND,
39-
user_message("Workspace was not found"),
39+
user_message("The requested workspace could not be found.", _version=1),
4040
),
4141
FolderAccessForbiddenError: HttpErrorInfo(
4242
status.HTTP_403_FORBIDDEN,
43-
user_message("Does not have access to this folder"),
43+
user_message("You do not have permission to access this folder.", _version=1),
4444
),
4545
WorkspaceAccessForbiddenError: HttpErrorInfo(
4646
status.HTTP_403_FORBIDDEN,
47-
user_message("Does not have access to this workspace"),
47+
user_message(
48+
"You do not have permission to access this workspace.", _version=1
49+
),
4850
),
4951
WorkspaceFolderInconsistencyError: HttpErrorInfo(
5052
status.HTTP_403_FORBIDDEN,
51-
user_message("This folder does not exist in this workspace"),
53+
user_message(
54+
"This folder is not available in the selected workspace.", _version=1
55+
),
5256
),
5357
FolderValueNotPermittedError: HttpErrorInfo(
5458
status.HTTP_409_CONFLICT,
55-
user_message("Provided folder value is not permitted: {reason}"),
59+
user_message("The folder operation cannot be completed: {reason}", _version=1),
5660
),
5761
FoldersValueError: HttpErrorInfo(
5862
status.HTTP_409_CONFLICT,
59-
user_message("Invalid folder value set: {reason}"),
63+
user_message("The folder configuration is invalid: {reason}", _version=1),
6064
),
6165
ProjectInvalidRightsError: HttpErrorInfo(
6266
status.HTTP_403_FORBIDDEN,
6367
user_message(
64-
"Access Denied: You do not have permission to move the project with UUID: {project_uuid}. Tip: Copy and paste the UUID into the search bar to locate the project."
68+
"You do not have permission to move the project with UUID: {project_uuid}. To locate this project, copy and paste the UUID into the search bar.",
69+
_version=1,
6570
),
6671
),
6772
# Trashing
6873
ProjectRunningConflictError: HttpErrorInfo(
6974
status.HTTP_409_CONFLICT,
7075
user_message(
71-
"One or more studies in this folder are in use and cannot be trashed. Please stop all services first and try again"
76+
"Cannot move folder to trash because it contains projects that are currently running. Please stop all running services first and try again.",
77+
_version=2,
7278
),
7379
),
7480
ProjectStoppingError: HttpErrorInfo(
7581
status.HTTP_503_SERVICE_UNAVAILABLE,
7682
user_message(
77-
"Something went wrong while stopping running services in studies within this folder before trashing. Aborting trash."
83+
"Something went wrong while stopping running services in projects within this folder before trashing. Aborting trash.",
84+
_version=2,
7885
),
7986
),
8087
}

services/web/server/src/simcore_service_webserver/groups/_common/exceptions_handlers.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,40 @@
2424
_TO_HTTP_ERROR_MAP: ExceptionToHttpErrorMap = {
2525
UserNotFoundError: HttpErrorInfo(
2626
status.HTTP_404_NOT_FOUND,
27-
user_message("User {uid} or {email} not found"),
27+
user_message(
28+
"The user with ID {uid} or email {email} could not be found.", _version=1
29+
),
2830
),
2931
GroupNotFoundError: HttpErrorInfo(
3032
status.HTTP_404_NOT_FOUND,
31-
user_message("Group {gid} not found"),
33+
user_message("The group with ID {gid} could not be found.", _version=1),
3234
),
3335
UserInGroupNotFoundError: HttpErrorInfo(
3436
status.HTTP_404_NOT_FOUND,
35-
user_message("User not found in group {gid}"),
37+
user_message("The user is not a member of group {gid}.", _version=1),
3638
),
3739
UserAlreadyInGroupError: HttpErrorInfo(
3840
status.HTTP_409_CONFLICT,
39-
user_message("User is already in group {gid}"),
41+
user_message("The user is already a member of group {gid}.", _version=1),
4042
),
4143
UserInsufficientRightsError: HttpErrorInfo(
4244
status.HTTP_403_FORBIDDEN,
43-
user_message("Insufficient rights for {permission} access to group {gid}"),
45+
user_message(
46+
"You do not have sufficient rights for {permission} access to group {gid}.",
47+
_version=1,
48+
),
4449
),
4550
# scicrunch
4651
InvalidRRIDError: HttpErrorInfo(
4752
status.HTTP_409_CONFLICT,
48-
user_message("Invalid RRID {rrid}"),
53+
user_message("The RRID {rrid} is not valid.", _version=1),
4954
),
5055
ScicrunchError: HttpErrorInfo(
5156
status.HTTP_409_CONFLICT,
52-
user_message("Cannot get RRID since scicrunch.org service is not reachable."),
57+
user_message(
58+
"Unable to retrieve RRID information because the scicrunch.org service is currently unavailable.",
59+
_version=1,
60+
),
5361
),
5462
}
5563

services/web/server/src/simcore_service_webserver/invitations/errors.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
"""
2-
API plugin errors
2+
API plugin errors
33
"""
44

5+
from common_library.user_messages import user_message
56

67
from ..errors import WebServerBaseError
78

8-
MSG_INVALID_INVITATION_URL = "Link seems corrupted or incomplete"
9-
MSG_INVITATION_ALREADY_USED = "This invitation was already used"
9+
MSG_INVALID_INVITATION_URL = user_message(
10+
"The invitation link appears to be corrupted or incomplete.", _version=1
11+
)
12+
MSG_INVITATION_ALREADY_USED = user_message(
13+
"This invitation has already been used and cannot be used again.", _version=1
14+
)
1015

1116

12-
class InvitationsError(WebServerBaseError, ValueError):
13-
...
17+
class InvitationsError(WebServerBaseError, ValueError): ...
1418

1519

1620
class InvalidInvitationError(InvitationsError):

services/web/server/src/simcore_service_webserver/licenses/_common/exceptions_handlers.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,30 @@
1818
_TO_HTTP_ERROR_MAP: ExceptionToHttpErrorMap = {
1919
LicensedItemNotFoundError: HttpErrorInfo(
2020
status.HTTP_404_NOT_FOUND,
21-
user_message("Market item {licensed_item_id} not found."),
21+
user_message(
22+
"The requested market item '{licensed_item_id}' could not be found.",
23+
_version=1,
24+
),
2225
),
2326
WalletAccessForbiddenError: HttpErrorInfo(
2427
status.HTTP_403_FORBIDDEN,
25-
user_message("Credit account {wallet_id} forbidden."),
28+
user_message(
29+
"You do not have permission to access credit account '{wallet_id}'.",
30+
_version=1,
31+
),
2632
),
2733
WalletNotEnoughCreditsError: HttpErrorInfo(
2834
status.HTTP_402_PAYMENT_REQUIRED,
29-
user_message("Not enough credits in the credit account."),
35+
user_message(
36+
"Your credit account does not have sufficient funds to complete this purchase.",
37+
_version=1,
38+
),
3039
),
3140
LicensedItemPricingPlanMatchError: HttpErrorInfo(
3241
status.HTTP_400_BAD_REQUEST,
3342
user_message(
34-
"The provided pricing plan does not match the one associated with the licensed item."
43+
"The selected pricing plan is not valid for this licensed item. Please choose a different plan.",
44+
_version=1,
3545
),
3646
),
3747
}

0 commit comments

Comments
 (0)