Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Bound bulk requests by serialized bytes as well as count
Count-limited batches can exceed payload limits when records contain variable-length text. Measure serialized UTF-8 bytes including operation metadata and delimiters, and handle a single oversized record explicitly.
Bad example
| 1 | for (const batch of chunks(records, 500)) await send(batch); |
Explanation (EN)
Count-limited batches can exceed payload limits when records contain variable-length text. Measure serialized UTF-8 bytes including operation metadata and delimiters, and handle a single oversized record explicitly.
Objašnjenje (HR)
Primjer ne provodi opisanu zastitu.
Good example
| 1 | for (const record of records) { |
| 2 | const bytes = Buffer.byteLength(serialize(record)); |
| 3 | if (bytes > maxBytes) throw new Error('Record too large'); |
| 4 | if (batch.count === maxCount || batch.bytes + bytes > maxBytes) await flush(); |
| 5 | append(record, bytes); |
| 6 | } |
| 7 | await flush(); |
Explanation (EN)
Use for bulk HTTP or database protocols with request-size limits. Preserve operation boundaries, include framing in byte accounting, and reject or route an oversized record according to the import contract. Test multi-byte text and a count boundary.
Objašnjenje (HR)
Provjeri uvjete prije operacije i sacuvaj jasno definirano ponasanje.
Notes (EN)
Use for bulk HTTP or database protocols with request-size limits. Preserve operation boundaries, include framing in byte accounting, and reject or route an oversized record according to the import contract. Test multi-byte text and a count boundary.
Bilješke (HR)
Primijeni kod spremanja podataka i skupnih operacija kada vrijede opisani uvjeti.
Exceptions / Tradeoffs (EN)
A provider that enforces a documented small per-record maximum may allow a mathematically proven count limit instead of measuring each batch.
Iznimke / Tradeoffi (HR)
Iznimke ovise o ugovoru sustava navedenom u engleskom opisu.