Principle:APIJSON APIJSON Demo Request Parsing Limits
| Knowledge Sources | |
|---|---|
| Domains | API_Design, Security, Performance |
| Last Updated | 2026-10-14 00:00 GMT |
Overview
Security and performance pattern that enforces configurable upper bounds on query complexity — maximum returned rows, update batch size, object count, and SQL statement count — to prevent resource exhaustion from expensive or malicious requests.
Description
Request Parsing Limits constrain what the APIJSON parser will accept, protecting the server from queries that could exhaust memory, overwhelm the database, or cause denial of service. The parser enforces four configurable limits:
- maxQueryCount: Maximum rows returned per query (default: 200, elevated to 1000 for internal calls)
- maxUpdateCount: Maximum objects modified per update request (default: 10)
- maxObjectCount: Maximum objects per request, equals maxUpdateCount (default: 10)
- maxSQLCount: Maximum SQL statements generated per request (default: 500)
These limits are enforced after JSON parsing but before SQL generation. Requests exceeding any limit are rejected with an error.
This solves:
- Unbounded queries: Without limits, a client could request
"User": { "id{}": [0-999999] }returning millions of rows. - Batch update abuse: A single PUT request could modify thousands of records; maxUpdateCount caps this at 10.
- Query complexity attacks: Deeply nested requests can generate many SQL statements; maxSQLCount limits this.
- Internal override: Trusted internal calls (via session key) can bypass limits for administrative operations.
Usage
Use this principle when:
- Building APIs that accept flexible queries and need protection against resource exhaustion.
- Different trust levels need different limits (external vs. internal calls).
- You want server-side enforced limits rather than relying on client-side restraint.
Theoretical Basis
Limits enforced in DemoParser:
getMaxQueryCount() → 200 (default), 1000 (internal key-authenticated)
getMaxUpdateCount() → 10
getMaxObjectCount() → getMaxUpdateCount() = 10
getMaxSQLCount() → 500
Internal Call Override:
parseResponse(request):
session = KEY_MAP.get(request.getString("key"))
if session != null:
request.remove("key")
maxQueryCount = 1000 // elevated limit for trusted calls
return super.parseResponse(request)
The KEY_MAP is a static map of session keys to HttpSession objects. When an internal call provides a valid key, the parser elevates the query limit to 1000, allowing bulk operations that external clients cannot perform.