Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f4aa5f2

Browse files
committedJan 8, 2025·
Provide a clearer error message when settings are missing midsession
1 parent 561f308 commit f4aa5f2

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed
 

‎err.txt

Whitespace-only changes.

‎frontend/__tests__/context/ws-client-provider.test.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,17 @@ describe("Propagate error message", () => {
2727
type: 'error'
2828
});
2929
});
30+
31+
it("should display error including translation id when present", () => {
32+
const message = "We have a problem!"
33+
const addErrorMessageSpy = vi.spyOn(ChatSlice, "addErrorMessage")
34+
updateStatusWhenErrorMessagePresent({message, data: {msg_id: '..id..'}})
35+
36+
expect(addErrorMessageSpy).toHaveBeenCalledWith({
37+
message,
38+
id: '..id..',
39+
status_update: true,
40+
type: 'error'
41+
});
42+
});
3043
});

‎frontend/src/context/ws-client-provider.tsx

+21-1
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,36 @@ interface WsClientProviderProps {
6767
conversationId: string;
6868
}
6969

70-
export function updateStatusWhenErrorMessagePresent(data: unknown) {
70+
interface ErrorArg {
71+
message?: string;
72+
data?: ErrorArgData | unknown;
73+
}
74+
75+
interface ErrorArgData {
76+
msg_id: string;
77+
}
78+
79+
export function updateStatusWhenErrorMessagePresent(data: ErrorArg | unknown) {
7180
if (
7281
data &&
7382
typeof data === "object" &&
7483
"message" in data &&
7584
typeof data.message === "string"
7685
) {
86+
let msgId: string | undefined;
87+
if (
88+
"data" in data &&
89+
data.data &&
90+
typeof data.data === "object" &&
91+
"msg_id" in data.data &&
92+
typeof data.data.msg_id === "string"
93+
) {
94+
msgId = data.data.msg_id;
95+
}
7796
handleStatusMessage({
7897
type: "error",
7998
message: data.message,
99+
id: msgId,
80100
status_update: true,
81101
});
82102
}

‎frontend/src/i18n/translation.json

+4
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@
454454
"fr": "Nous avons modifié certains paramètres dans la dernière mise à jour. Prenez un moment pour les examiner.",
455455
"tr": "Son güncellemede bazı ayarları değiştirdik. Gözden geçirmek için bir dakikanızı ayırın."
456456
},
457+
"CONFIGURATION$SETTINGS_NOT_FOUND": {
458+
"en": "Settings not found. Please check your API key",
459+
"es": "Configuraciones no encontradas. Por favor revisa tu API key"
460+
},
457461
"CONFIGURATION$AGENT_LOADING": {
458462
"en": "Please wait while the agent loads. This may take a few minutes...",
459463
"de": "Bitte warten Sie, während der Agent lädt. Das kann ein paar Minuten dauern...",

‎openhands/server/listen_socket.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ async def connect(connection_id: str, environ, auth):
5757
settings = await settings_store.load()
5858

5959
if not settings:
60-
raise ConnectionRefusedError('Settings not found')
60+
raise ConnectionRefusedError(
61+
'Settings not found', {'msg_id': 'CONFIGURATION$SETTINGS_NOT_FOUND'}
62+
)
6163

6264
try:
6365
event_stream = await session_manager.join_conversation(

0 commit comments

Comments
 (0)
Please sign in to comment.