Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Verify an existing storage schema before enabling writes
An already-existing resource is not evidence that its schema satisfies the reader and writer contract. Verify required mappings and fail before enabling operations if they are incompatible.
Bad example
| 1 | try { await createIndex(schema); } catch (error) { |
| 2 | if (!isAlreadyExists(error)) throw error; |
| 3 | } |
Explanation (EN)
An already-existing resource is not evidence that its schema satisfies the reader and writer contract. Verify required mappings and fail before enabling operations if they are incompatible.
Objašnjenje (HR)
Primjer ne provodi opisanu zastitu.
Good example
| 1 | try { await createIndex(schema); } catch (error) { |
| 2 | if (!isAlreadyExists(error)) throw error; |
| 3 | assertCompatible(await readMapping(), schema); |
| 4 | } |
Explanation (EN)
Use when startup reuses an existing index, collection or table whose field types affect filtering, sorting or decoding. Distinguish unrelated existing-resource errors from the expected duplicate. Verify only required invariants and never silently delete data to repair a mismatch.
Objašnjenje (HR)
Provjeri uvjete prije operacije i sacuvaj jasno definirano ponasanje.
Notes (EN)
Use when startup reuses an existing index, collection or table whose field types affect filtering, sorting or decoding. Distinguish unrelated existing-resource errors from the expected duplicate. Verify only required invariants and never silently delete data to repair a mismatch.
Bilješke (HR)
Primijeni kod spremanja podataka i skupnih operacija kada vrijede opisani uvjeti.
Exceptions / Tradeoffs (EN)
An independently enforced schema migration and verified schema version may replace field-by-field startup validation.
Iznimke / Tradeoffi (HR)
Iznimke ovise o ugovoru sustava navedenom u engleskom opisu.