Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Treat missing-document deletes as idempotent success
For an idempotent delete, a confirmed already-absent document satisfies the operation. Inspect the per-item operation and error body instead of rejecting every non-2xx bulk result.
Bad example
| 1 | if (result.status >= 300) throw new Error('Bulk failed'); |
Explanation (EN)
For an idempotent delete, a confirmed already-absent document satisfies the operation. Inspect the per-item operation and error body instead of rejecting every non-2xx bulk result.
Objašnjenje (HR)
Primjer ne provodi opisanu zastitu.
Good example
| 1 | const absent = operation === 'delete' && result.status === 404 && result.result === 'not_found' && !result.error; |
| 2 | if (!absent && (result.error || result.status < 200 || result.status >= 300)) throw new Error('Bulk failed'); |
Explanation (EN)
Apply to repeated or overlapping cleanup where a near-real-time search can still return a document deleted by another attempt. Keep checking each result and expected item counts. A missing index, authorization failure or missing write target is not an idempotent success.
Objašnjenje (HR)
Provjeri uvjete prije operacije i sacuvaj jasno definirano ponasanje.
Notes (EN)
Apply to repeated or overlapping cleanup where a near-real-time search can still return a document deleted by another attempt. Keep checking each result and expected item counts. A missing index, authorization failure or missing write target is not an idempotent success.
Bilješke (HR)
Primijeni kod spremanja podataka i skupnih operacija kada vrijede opisani uvjeti.
Exceptions / Tradeoffs (EN)
If the API contract requires proving a record existed and was removed by this request, an already-absent response can remain a distinct result.
Iznimke / Tradeoffi (HR)
Iznimke ovise o ugovoru sustava navedenom u engleskom opisu.