Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(catalog): correct the catalog 503 and send-product 404 text

Yudhi Armyndharis2a836c72ae83
diff --git a/src/modules/catalog/catalog.controller.spec.ts b/src/modules/catalog/catalog.controller.spec.ts
index eaba05b9f..b9ae1edb7 100644
--- a/src/modules/catalog/catalog.controller.spec.ts
+++ b/src/modules/catalog/catalog.controller.spec.ts
@@ -1,6 +1,7 @@
import { CatalogController } from './catalog.controller';
import type { CatalogService } from './catalog.service';
import type { Catalog, PaginatedProducts, Product } from '../../engine/interfaces/whatsapp-engine.interface';
+import { SESSION_NOT_STARTED_404 } from '../../common/openapi/engine-status-responses';
/**
* The controller is a thin map from route params/DTOs onto CatalogService's positional arguments.
@@ -49,4 +50,25 @@ describe('CatalogController', () => {
await expect(controller.sendProduct('s1', dto)).resolves.toBe(sent);
expect(service.sendProduct).toHaveBeenCalledWith('s1', '[email protected]', 'prod-1', 'Back in stock!');
});
+
+ const declared = (handler: keyof CatalogController): Record<string, { description?: string }> =>
+ (Reflect.getMetadata(
+ 'swagger/apiResponse',
+ Object.getOwnPropertyDescriptor(CatalogController.prototype, handler)?.value as object,
+ ) ?? {}) as Record<string, { description?: string }>;
+
+ // For some accounts WhatsApp never answers the catalog query, so the 503 must not promise that a
+ // retry clears it.
+ it.each(['getCatalog', 'getProducts', 'getProduct', 'sendProduct'] as const)(
+ 'does not tell %s callers a catalog timeout clears on retry',
+ handler => {
+ expect(declared(handler)['503']?.description).not.toMatch(/retry shortly/);
+ },
+ );
+
+ // CatalogService.sendProduct resolves the engine with a NotFoundException, so an unstarted session
+ // answers 404 here too, not only a missing product.
+ it('documents the unstarted-session 404 on send-product', () => {
+ expect(declared('sendProduct')['404']?.description).toContain(SESSION_NOT_STARTED_404);
+ });
});
diff --git a/src/modules/catalog/catalog.controller.ts b/src/modules/catalog/catalog.controller.ts
index f4d0dbbdc..e8d156e00 100644
--- a/src/modules/catalog/catalog.controller.ts
+++ b/src/modules/catalog/catalog.controller.ts
@@ -12,7 +12,9 @@ import { ENGINE_NOT_READY_409, SESSION_NOT_STARTED_404 } from '../../common/open
* unanswered for an account without a catalog. The adapter bounds that walk with its own budget
* rather than reporting an unanswered query as an empty catalog.
*/
-const CATALOG_TIMEOUT_503 = 'WhatsApp did not answer the catalog query within the request budget — retry shortly.';
+const CATALOG_TIMEOUT_503 =
+ 'WhatsApp did not answer the catalog query within the request budget. For some business accounts ' +
+ 'WhatsApp never answers it, so a retry may not help.';
@ApiTags('catalog')
@Controller('sessions/:sessionId')
@@ -74,7 +76,7 @@ export class CatalogController {
@RequireRole(ApiKeyRole.OPERATOR)
@ApiOperation({ summary: 'Send a product message (Baileys engine only)' })
@ApiResponse({ status: 201, description: 'Product message accepted for sending', type: ProductMessageResponseDto })
- @ApiResponse({ status: 404, description: 'Product id not found in the session catalog.' })
+ @ApiResponse({ status: 404, description: 'Product id not found in the session catalog. ' + SESSION_NOT_STARTED_404 })
@ApiResponse({
status: 400,
description: