Skip to content

Enforce API payload size limits and query result caps (#1630)#1925

Draft
AkramBitar wants to merge 1 commit into
mainfrom
feature/1630-api-payload-and-query-bounds
Draft

Enforce API payload size limits and query result caps (#1630)#1925
AkramBitar wants to merge 1 commit into
mainfrom
feature/1630-api-payload-and-query-bounds

Conversation

@AkramBitar

Copy link
Copy Markdown
Contributor

Enforce upper bounds at the SQL transaction-store chokepoint so a single oversized write or unbounded scan cannot monopolise DB resources.

  • Write cap: AddTokenRequest/AddTransaction/AddMovement reject payloads over a max size (default 4 MiB; 0 disables).
  • Read caps: QueryTransactions requires bounded pagination (rejects nil/None); QueryTokenRequests is hard-LIMITed to the max page size (default 1000). QueryMovements is intentionally excluded (balance aggregation).
  • Limits default via consts, overridable from config (token.storage.maxPayloadSize / maxPageSize) or WithMax* options.
  • Unbounded callers migrated to bounded page loops.

Closes #1630.

…1630)

Add upper bounds at the SQL transaction-store chokepoint so a single
oversized write or unbounded scan cannot monopolise DB resources:

- Write cap: AddTokenRequest/AddTransaction/AddMovement reject payloads
  over a max size (DefaultMaxPayloadSize 4 MiB; 0 disables).
- Read caps: QueryTransactions requires bounded pagination (rejects
  nil/None); QueryTokenRequests is hard-LIMITed to the max page size
  (DefaultMaxPageSize 1000). QueryMovements is intentionally excluded.
- Limits default via consts and are overridable from config
  (token.storage.maxPayloadSize / maxPageSize) or WithMax* options.
- Migrate unbounded callers (checks.go, history views) to page loops.

Signed-off-by: AkramBitar <akram@il.ibm.com>
@AkramBitar AkramBitar marked this pull request as draft July 15, 2026 14:06
@AkramBitar AkramBitar self-assigned this Jul 15, 2026
@AkramBitar AkramBitar added this to the Q3/26 milestone Jul 15, 2026
@AkramBitar AkramBitar changed the title feat(storage): enforce API payload size limits and query result caps (#1630) Enforce API payload size limits and query result caps (#1630) Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API-level payload size limits and query result caps [MED]

1 participant