Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(search): give the real reason for the date bound

Yudhi Armyndharis354f7dbd3e2b
diff --git a/docs/26-global-search.md b/docs/26-global-search.md
index 7204f08d6..d757cddb8 100644
--- a/docs/26-global-search.md
+++ b/docs/26-global-search.md
@@ -137,7 +137,7 @@ GET /api/search?q=<term>&sessionId=<id>&chatId=<id>&direction=<incoming|outgoing
longer than 1000 characters or with more than 32 words, punctuation separating words as whitespace does and a symbol or emoji that stands apart counting as one; a whitespace-separated word said again counts once). Numeric params
are coerced and validated; a non-numeric `limit`/`offset`/`dateFrom`/`dateTo` surfaces as `400`,
never as a `NaN` SQL parameter, and so does a `dateFrom`/`dateTo` beyond 9007199254740991 in either direction
- (no timestamp reaches it, and PostgreSQL would reject the bound as an overflow).
+ (no timestamp reaches it, and the cap keeps the value exactly representable, on both databases).
- **Auth scoping is authoritative.** The caller's API-key `allowedSessions` is injected by
`SearchService` — **never** accepted from the query — so a scoped key cannot broaden its reach. A
key with a non-empty `allowedSessions` searches only those sessions, whatever its role, even if it
diff --git a/src/modules/search/dto/search-query.dto.ts b/src/modules/search/dto/search-query.dto.ts
index b4ab7b682..02bd3b6ef 100644
--- a/src/modules/search/dto/search-query.dto.ts
+++ b/src/modules/search/dto/search-query.dto.ts
@@ -10,8 +10,9 @@ import { SEARCH_OFFSET_MAX, SEARCH_QUERY_MAX_LENGTH, SEARCH_TERMS_MAX } from '..
* Request shape for GET /search. Numeric fields are coerced from query-string strings via
* `@Type(() => Number)` and then validated, so `?limit=abc` (Number('abc') → NaN) surfaces as a 400
* from the global ValidationPipe, never reaching the provider as a NaN SQL param. The epoch-ms
- * bounds `dateFrom`/`dateTo` use `@IsNumber()` within the safe integer range, since the provider binds them
- * as seconds into a bigint column that a larger value overflows; `limit`/`offset` use `@IsInt()`, because they are
+ * bounds `dateFrom`/`dateTo` use `@IsNumber()` within the safe integer range: beyond it a number is no longer an
+ * exact integer and no timestamp reaches it, and the cap is the DTO's own, so it holds on both databases (a
+ * bigint column only overflows far above it, on PostgreSQL); `limit`/`offset` use `@IsInt()`, because they are
* bound straight into `LIMIT ?`/`OFFSET ?` where better-sqlite3 rejects a fractional value with
* SQLITE_MISMATCH: a fraction has to be a 400 here rather than a driver-level 500. `sessionIds` and
* `chatIds` are intentionally absent: both scopes are injected by SearchService from the caller's