Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(message): correct the 400 text of react and delete

Yudhi Armyndharis007eb5825434
diff --git a/openapi.json b/openapi.json
index c55a4a11b..df683c706 100644
--- a/openapi.json
+++ b/openapi.json
@@ -6249,7 +6249,7 @@
}
},
"400": {
- "description": "Session not active or message not found",
+ "description": "Session not active",
"content": {
"application/json": {
"schema": {
@@ -6839,7 +6839,7 @@
}
},
"400": {
- "description": "Session not active or message not found",
+ "description": "Session not active",
"content": {
"application/json": {
"schema": {
diff --git a/src/modules/message/message.controller.spec.ts b/src/modules/message/message.controller.spec.ts
index d1c20a2b9..1101bd658 100644
--- a/src/modules/message/message.controller.spec.ts
+++ b/src/modules/message/message.controller.spec.ts
@@ -316,4 +316,16 @@ describe('MessageController OpenAPI error responses', () => {
) as Record<string, unknown>;
expect(Object.keys(responses)).toContain('400');
});
+
+ // An unknown message answers 404 (MessageNotFoundError), which these routes declare on its own, so
+ // their 400 is only the missing live engine. A client reading the 400 as "message not found" would
+ // never handle the 404 the engine actually raises.
+ it.each(['react', 'deleteMessage'])('%s keeps "message not found" out of its 400', method => {
+ const responses = Reflect.getMetadata(
+ 'swagger/apiResponse',
+ Object.getOwnPropertyDescriptor(MessageController.prototype, method)!.value as object,
+ ) as Record<string, { description: string }>;
+ expect(responses['400'].description).toBe('Session not active');
+ expect(Object.keys(responses)).toContain('404');
+ });
});
diff --git a/src/modules/message/message.controller.ts b/src/modules/message/message.controller.ts
index b9cc437c0..a17d0fdb0 100644
--- a/src/modules/message/message.controller.ts
+++ b/src/modules/message/message.controller.ts
@@ -548,7 +548,7 @@ export class MessageController {
})
@ApiResponse({
status: 400,
- description: 'Session not active or message not found',
+ description: 'Session not active',
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
@ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
@@ -784,7 +784,7 @@ export class MessageController {
})
@ApiResponse({
status: 400,
- description: 'Session not active or message not found',
+ description: 'Session not active',
})
@ApiResponse({
status: 503,